mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
cmd: factor FlagName into fs.Option #2541
This commit is contained in:
14
fs/fs.go
14
fs/fs.go
@@ -154,6 +154,20 @@ func (o *Option) Type() string {
|
||||
return reflect.TypeOf(o.value()).Name()
|
||||
}
|
||||
|
||||
// FlagName for the option
|
||||
func (o *Option) FlagName(prefix string) string {
|
||||
name := strings.Replace(o.Name, "_", "-", -1) // convert snake_case to kebab-case
|
||||
if !o.NoPrefix {
|
||||
name = prefix + "-" + name
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
// EnvVarName for the option
|
||||
func (o *Option) EnvVarName(prefix string) string {
|
||||
return OptionToEnv(prefix + "-" + o.Name)
|
||||
}
|
||||
|
||||
// OptionExamples is a slice of examples
|
||||
type OptionExamples []OptionExample
|
||||
|
||||
|
||||
Reference in New Issue
Block a user