Skip to content

Commit

Permalink
Allow colons in command portion of template flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanner Bruce authored and sethvargo committed Oct 30, 2017
1 parent 873596d commit d12253b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ func ParseTemplateConfig(s string) (*TemplateConfig, error) {
case 3:
source, destination, command = parts[0], parts[1], parts[2]
default:
return nil, ErrTemplateInvalidFormat
source, destination = parts[0], parts[1]
command = strings.Join(parts[2:], ":")
}

var sourcePtr, destinationPtr, commandPtr *string
Expand Down
32 changes: 26 additions & 6 deletions config/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,6 @@ func TestParseTemplateConfig(t *testing.T) {
nil,
true,
},
{
"too_many_args",
"foo:bar:zip:zap",
nil,
true,
},
{
"default",
"/tmp/a.txt:/tmp/b.txt:command",
Expand All @@ -513,6 +507,22 @@ func TestParseTemplateConfig(t *testing.T) {
},
false,
},
{
"single",
"/tmp/a.txt",
&TemplateConfig{
Source: String("/tmp/a.txt"),
},
false,
},
{
"single_windows_drive",
`z:\foo`,
&TemplateConfig{
Source: String(`z:\foo`),
},
false,
},
{
"windows_drives",
`C:\abc\123:D:\xyz\789:command`,
Expand All @@ -523,6 +533,16 @@ func TestParseTemplateConfig(t *testing.T) {
},
false,
},
{
"windows_drives_with_colon",
`C:\abc\123:D:\xyz\789:sub:command`,
&TemplateConfig{
Source: String(`C:\abc\123`),
Destination: String(`D:\xyz\789`),
Command: String(`sub:command`),
},
false,
},
}

for i, tc := range cases {
Expand Down

0 comments on commit d12253b

Please sign in to comment.