Move hard out of flag args and into command
This commit is contained in:
@@ -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)
|
||||
|
3
main.go
3
main.go
@@ -32,13 +32,10 @@ var DirRegex, _ = regexp.Compile(`^(.+?)[/\\]sync$`)
|
||||
var FileRegex, _ = regexp.Compile(`^sync$`)
|
||||
var programName = os.Args[0]
|
||||
|
||||
var hard *bool
|
||||
|
||||
func main() {
|
||||
recurse := flag.String("r", "", "recurse into directories")
|
||||
file := flag.String("f", "", "file to read instructions from")
|
||||
debug := flag.Bool("d", false, "debug")
|
||||
hard = flag.Bool("h", false, "create hard links instead")
|
||||
flag.Parse()
|
||||
|
||||
if *debug {
|
||||
|
3
sync
3
sync
@@ -1 +1,2 @@
|
||||
main.exe,"C:\Program Files\Git\usr\bin\cln.exe",t
|
||||
main.exe,"C:\Program Files\Git\usr\bin\cln.exe",t
|
||||
main.exe,"~/Seafile/Other/cln.exe",,t
|
Reference in New Issue
Block a user