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:
@ -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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user