2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

ls: Explicitly enforce that the user specifies a snapshot ID

The help messages suggested that the `ls` command work without
explicitly passing a snapshot ID. However, this was never the case:
without a snapshot ID the command just failed with the error
`Ignoring "", it is not a snapshot id`.

Fixes #2299
This commit is contained in:
Michael Eischer 2020-08-29 14:28:53 +02:00
parent c34c731698
commit d5f86effa1

View File

@ -16,7 +16,7 @@ import (
)
var cmdLs = &cobra.Command{
Use: "ls [flags] [snapshotID] [dir...]",
Use: "ls [flags] snapshotID [dir...]",
Short: "List files in a snapshot",
Long: `
The "ls" command lists files and directories in a snapshot.
@ -89,8 +89,8 @@ type lsNode struct {
}
func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
if len(args) == 0 && len(opts.Hosts) == 0 && len(opts.Tags) == 0 && len(opts.Paths) == 0 {
return errors.Fatal("Invalid arguments, either give one or more snapshot IDs or set filters.")
if len(args) == 0 {
return errors.Fatal("no snapshot ID specified")
}
// extract any specific directories to walk