1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-25 02:16:56 +08:00

commands: Added Recursive modifier to Argument

This commit is contained in:
Matt Bell
2014-11-16 19:12:55 -08:00
parent bfc83bd16a
commit f22ac196bb

View File

@ -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
}