mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 00:06:25 +00:00
allow argumentless flags
This commit is contained in:
parent
2789502c89
commit
6137e31c3b
@ -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…
Reference in New Issue
Block a user