allow argumentless flags

pull/114/head
cupcakearmy 3 years ago
parent 2789502c89
commit 6137e31c3b
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9

@ -18,6 +18,8 @@ backend:
In this example, whenever `autorestic` runs `restic backup` it will append a `--tag abc --tag` to the native command.
For more detail see the [location docs](/location/options) for options, as they are the same
For more detail see the [location docs](/location/options) for options, as they are the same.
> For flags without arguments you can set them to `true`. They will be handled accordingly.
> :ToCPrevNext

@ -18,4 +18,6 @@ locations:
In this example, whenever `autorestic` runs `restic backup` it will append a `--tag abc --tag` to the native command.
> For flags without arguments you can set them to `true`. They will be handled accordingly.
> :ToCPrevNext

@ -239,7 +239,18 @@ func getOptions(options Options, key string) []string {
var selected []string
for k, values := range options[key] {
for _, value := range values {
selected = append(selected, fmt.Sprintf("--%s", k), value)
// Bool
asBool, ok := value.(bool)
if ok && asBool {
selected = append(selected, fmt.Sprintf("--%s", k))
continue
}
// String
asString, ok := value.(string)
if ok {
selected = append(selected, fmt.Sprintf("--%s", k), asString)
continue
}
}
}
return selected

@ -30,7 +30,7 @@ type Hooks struct {
Failure HookArray `yaml:"failure,omitempty"`
}
type Options map[string]map[string][]string
type Options map[string]map[string][]interface{}
type Location struct {
name string `yaml:",omitempty"`

Loading…
Cancel
Save