Commit f22ac196 authored by Matt Bell's avatar Matt Bell

commands: Added Recursive modifier to Argument

parent bfc83bd1
......@@ -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
}
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