Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
f22ac196
Commit
f22ac196
authored
Nov 16, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Added Recursive modifier to Argument
parent
bfc83bd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
commands/argument.go
commands/argument.go
+17
-3
No files found.
commands/argument.go
View file @
f22ac196
...
...
@@ -10,9 +10,10 @@ const (
type
Argument
struct
{
Name
string
Type
ArgumentType
Required
bool
Variadic
bool
SupportsStdin
bool
Required
bool
// error if no value is specified
Variadic
bool
// unlimited values can be specfied
SupportsStdin
bool
// can accept stdin as a value
Recursive
bool
// supports recursive file adding (with '-r' flag)
Description
string
}
...
...
@@ -36,7 +37,20 @@ func FileArg(name string, required, variadic bool, description string) Argument
}
}
// TODO: modifiers might need a different API?
// e.g. passing enum values into arg constructors variadically
// (`FileArg("file", ArgRequired, ArgStdin, ArgRecursive)`)
func
(
a
Argument
)
EnableStdin
()
Argument
{
a
.
SupportsStdin
=
true
return
a
}
func
(
a
Argument
)
EnableRecursive
()
Argument
{
if
a
.
Type
!=
ArgFile
{
panic
(
"Only ArgFile arguments can enable recursive"
)
}
a
.
Recursive
=
true
return
a
}
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