Skip to content

Commit

Permalink
Allow the arg="value" format in alias definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Duchesne committed May 1, 2019
1 parent d4cfa99 commit b2a709c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (config *TGFConfig) ParseAliases(args []string) []string {
result = replace.Fields()
if len(quoted) > 0 {
for i := range result {
result[i] = result[i].RestoreProtected(quoted).Trim(`"`)
result[i] = result[i].RestoreProtected(quoted).ReplaceN(`="`, "=", 1).Trim(`"`)
}
}
return append(config.ParseAliases(result.Strings()), args[1:]...)
Expand Down
4 changes: 2 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestParseAliases(t *testing.T) {
Aliases: map[string]string{
"to_replace": "one two three,four",
"other_arg1": "will not be replaced",
"with_quote": `quoted arg1 "arg 2" -D -it --rm`,
"with_quote": `quoted arg1 "arg 2" arg3="arg4 arg5" -D -it --rm`,
"recursive": "to_replace five",
},
}
Expand All @@ -196,7 +196,7 @@ func TestParseAliases(t *testing.T) {
{"Unchanged", config, strings.Split("whatever the args are", " "), []string{"whatever", "the", "args", "are"}},
{"Replaced", config, strings.Split("to_replace with some args", " "), []string{"one", "two", "three,four", "with", "some", "args"}},
{"Replaced 2", config, strings.Split("to_replace other_arg1", " "), []string{"one", "two", "three,four", "other_arg1"}},
{"Replaced with quote", config, strings.Split("with_quote 1 2 3", " "), []string{"quoted", "arg1", "arg 2", "-D", "-it", "--rm", "1", "2", "3"}},
{"Replaced with quote", config, strings.Split("with_quote 1 2 3", " "), []string{"quoted", "arg1", "arg 2", "arg3=arg4 arg5", "-D", "-it", "--rm", "1", "2", "3"}},
{"Recursive", config, strings.Split("recursive", " "), []string{"one", "two", "three,four", "five"}},
}

Expand Down

0 comments on commit b2a709c

Please sign in to comment.