Merge pull request #905 from restic/fix-json-output
Remove short option conflict
This commit is contained in:
commit
dc8493535d
2 changed files with 28 additions and 2 deletions
|
@ -44,8 +44,8 @@ func init() {
|
||||||
cmdRoot.AddCommand(cmdFind)
|
cmdRoot.AddCommand(cmdFind)
|
||||||
|
|
||||||
f := cmdFind.Flags()
|
f := cmdFind.Flags()
|
||||||
f.StringVarP(&findOptions.Oldest, "oldest", "o", "", "oldest modification date/time")
|
f.StringVarP(&findOptions.Oldest, "oldest", "O", "", "oldest modification date/time")
|
||||||
f.StringVarP(&findOptions.Newest, "newest", "n", "", "newest modification date/time")
|
f.StringVarP(&findOptions.Newest, "newest", "N", "", "newest modification date/time")
|
||||||
f.StringSliceVarP(&findOptions.Snapshots, "snapshot", "s", nil, "snapshot `id` to search in (can be given multiple times)")
|
f.StringSliceVarP(&findOptions.Snapshots, "snapshot", "s", nil, "snapshot `id` to search in (can be given multiple times)")
|
||||||
f.BoolVarP(&findOptions.CaseInsensitive, "ignore-case", "i", false, "ignore case for pattern")
|
f.BoolVarP(&findOptions.CaseInsensitive, "ignore-case", "i", false, "ignore case for pattern")
|
||||||
f.BoolVarP(&findOptions.ListLong, "long", "l", false, "use a long listing format showing size and mode")
|
f.BoolVarP(&findOptions.ListLong, "long", "l", false, "use a long listing format showing size and mode")
|
||||||
|
|
26
src/cmds/restic/flags_test.go
Normal file
26
src/cmds/restic/flags_test.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestFlags checks for double defined flags, the commands will panic on
|
||||||
|
// ParseFlags() when a shorthand flag is defined twice.
|
||||||
|
func TestFlags(t *testing.T) {
|
||||||
|
type FlagParser interface {
|
||||||
|
ParseFlags([]string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, cmd := range cmdRoot.Commands() {
|
||||||
|
t.Run(cmd.Name(), func(t *testing.T) {
|
||||||
|
err := cmd.ParseFlags([]string{"--help"})
|
||||||
|
if err.Error() == "pflag: help requested" {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue