diff --git a/instruction.go b/instruction.go index 4ff5c02..7bd9d5e 100644 --- a/instruction.go +++ b/instruction.go @@ -18,6 +18,16 @@ type LinkInstruction struct { Delete bool } +func (instruction *LinkInstruction) Tidy() { + instruction.Source = strings.ReplaceAll(instruction.Source, "\"", "") + instruction.Source = strings.ReplaceAll(instruction.Source, "\\", "/") + instruction.Source = strings.TrimSpace(instruction.Source) + + instruction.Target = strings.ReplaceAll(instruction.Target, "\"", "") + instruction.Target = strings.ReplaceAll(instruction.Target, "\\", "/") + instruction.Target = strings.TrimSpace(instruction.Target) +} + func (instruction *LinkInstruction) String() string { return fmt.Sprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s", SourceColor, instruction.Source, DefaultColor, deliminer, TargetColor, instruction.Target, DefaultColor, deliminer, strconv.FormatBool(instruction.Force), deliminer, strconv.FormatBool(instruction.Hard), deliminer, strconv.FormatBool(instruction.Delete)) } @@ -48,6 +58,7 @@ func ParseInstruction(line, workdir string) (LinkInstruction, error) { instruction.Force = res } + instruction.Tidy() instruction.Source, _ = ConvertHome(instruction.Source) instruction.Target, _ = ConvertHome(instruction.Target) diff --git a/sync b/sync new file mode 100644 index 0000000..6039d88 --- /dev/null +++ b/sync @@ -0,0 +1 @@ +foo,"~/bar" \ No newline at end of file diff --git a/testsync b/testsync deleted file mode 100644 index 2a6f6f3..0000000 --- a/testsync +++ /dev/null @@ -1 +0,0 @@ -foo,bar,,t \ No newline at end of file