diff --git a/commands/argument.go b/commands/argument.go index fb4b74b74..2bfe1cdfa 100644 --- a/commands/argument.go +++ b/commands/argument.go @@ -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 +}