list: Improve error message

Before:

    $ restic list
    Fatal: type not specified

After:

    $ restic list
    Fatal: type not specified, usage: list [blobs|packs|index|snapshots|keys|locks]

Closes #1783
This commit is contained in:
Alexander Neumann 2018-05-17 19:41:56 +02:00
parent ecfe59235e
commit 8d9d218d1c
2 changed files with 4 additions and 4 deletions

View file

@ -18,7 +18,7 @@ The "list" command allows listing objects in the repository based on type.
`,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runList(globalOptions, args)
return runList(cmd, globalOptions, args)
},
}
@ -26,9 +26,9 @@ func init() {
cmdRoot.AddCommand(cmdList)
}
func runList(opts GlobalOptions, args []string) error {
func runList(cmd *cobra.Command, opts GlobalOptions, args []string) error {
if len(args) != 1 {
return errors.Fatal("type not specified")
return errors.Fatal("type not specified, usage: " + cmd.Use)
}
repo, err := OpenRepository(opts)

View file

@ -86,7 +86,7 @@ func testRunList(t testing.TB, tpe string, opts GlobalOptions) restic.IDs {
globalOptions.stdout = os.Stdout
}()
rtest.OK(t, runList(opts, []string{tpe}))
rtest.OK(t, runList(cmdList, opts, []string{tpe}))
return parseIDsFromReader(t, buf)
}