Commit f22ac196 authored by Matt Bell's avatar Matt Bell

commands: Added Recursive modifier to Argument

parent bfc83bd1
...@@ -10,9 +10,10 @@ const ( ...@@ -10,9 +10,10 @@ const (
type Argument struct { type Argument struct {
Name string Name string
Type ArgumentType Type ArgumentType
Required bool Required bool // error if no value is specified
Variadic bool Variadic bool // unlimited values can be specfied
SupportsStdin bool SupportsStdin bool // can accept stdin as a value
Recursive bool // supports recursive file adding (with '-r' flag)
Description string Description string
} }
...@@ -36,7 +37,20 @@ func FileArg(name string, required, variadic bool, description string) Argument ...@@ -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 { func (a Argument) EnableStdin() Argument {
a.SupportsStdin = true a.SupportsStdin = true
return a return a
} }
func (a Argument) EnableRecursive() Argument {
if a.Type != ArgFile {
panic("Only ArgFile arguments can enable recursive")
}
a.Recursive = true
return a
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment