Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
eee06637
Commit
eee06637
authored
Jun 26, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support -flag=var1,var2,var3 to fix #2332
parent
e112d9b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
helper/flag-slice/flag.go
helper/flag-slice/flag.go
+1
-1
helper/flag-slice/flag_test.go
helper/flag-slice/flag_test.go
+17
-0
No files found.
helper/flag-slice/flag.go
View file @
eee06637
...
...
@@ -11,6 +11,6 @@ func (s *StringFlag) String() string {
}
func
(
s
*
StringFlag
)
Set
(
value
string
)
error
{
*
s
=
append
(
*
s
,
value
)
*
s
=
append
(
*
s
,
strings
.
Split
(
value
,
","
)
...
)
return
nil
}
helper/flag-slice/flag_test.go
View file @
eee06637
...
...
@@ -14,6 +14,8 @@ func TestStringFlag_implements(t *testing.T) {
}
}
// TestStringFlagSet tests for setting the same flag more than once on the CLI
// like: blah -flag foo -flag bar
func
TestStringFlagSet
(
t
*
testing
.
T
)
{
sv
:=
new
(
StringFlag
)
err
:=
sv
.
Set
(
"foo"
)
...
...
@@ -31,3 +33,18 @@ func TestStringFlagSet(t *testing.T) {
t
.
Fatalf
(
"Bad: %#v"
,
sv
)
}
}
// TestMultiStringFlag tests for setting the same flag using a comma-separated
// list of items like: blah -flag=foo,bar
func
TestMultiStringFlag
(
t
*
testing
.
T
)
{
sv
:=
new
(
StringFlag
)
err
:=
sv
.
Set
(
"chocolate,vanilla"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err :%s"
,
err
)
}
expected
:=
[]
string
{
"chocolate"
,
"vanilla"
}
if
!
reflect
.
DeepEqual
([]
string
(
*
sv
),
expected
)
{
t
.
Fatalf
(
"Expected: %#v, found: %#v"
,
expected
,
sv
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment