Move hard out of flag args and into command

This commit is contained in:
2024-08-16 09:38:35 +02:00
parent 1f21965288
commit 2c49b65502
4 changed files with 9 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ type LinkInstruction struct {
Source string
Target string
Force bool
Hard bool
}
func (instruction *LinkInstruction) String() string {
@@ -35,6 +36,10 @@ func ParseInstruction(line string) (LinkInstruction, error) {
res, _ := regexp.MatchString(`^(?i)\s*T|TRUE\s*$`, parts[2])
instruction.Force = res
}
if len(parts) > 3 {
res, _ := regexp.MatchString(`^(?i)\s*T|TRUE\s*$`, parts[3])
instruction.Hard = res
}
instruction.Source, _ = ConvertHome(instruction.Source)
instruction.Target, _ = ConvertHome(instruction.Target)
@@ -123,7 +128,7 @@ func (instruction *LinkInstruction) RunAsync(status chan (error)) {
}
var err error
if *hard {
if instruction.Hard {
err = os.Link(instruction.Source, instruction.Target)
} else {
err = os.Symlink(instruction.Source, instruction.Target)