2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-21 12:25:09 +00:00

ls: only allow either --json or --ncdu

This commit is contained in:
Michael Eischer 2024-01-21 16:09:05 +01:00
parent a2f2f8fb4c
commit 261737abc8

View File

@ -66,7 +66,7 @@ func init() {
flags.BoolVarP(&lsOptions.ListLong, "long", "l", false, "use a long listing format showing size and mode")
flags.BoolVar(&lsOptions.Recursive, "recursive", false, "include files in subfolders of the listed directories")
flags.BoolVar(&lsOptions.HumanReadable, "human-readable", false, "print sizes in human readable format")
flags.BoolVar(&lsOptions.Ncdu, "ncdu", false, "output NCDU save format (pipe into 'ncdu -f -')")
flags.BoolVar(&lsOptions.Ncdu, "ncdu", false, "output NCDU export format (pipe into 'ncdu -f -')")
}
type lsPrinter interface {
@ -256,6 +256,9 @@ func runLs(ctx context.Context, opts LsOptions, gopts GlobalOptions, args []stri
if len(args) == 0 {
return errors.Fatal("no snapshot ID specified, specify snapshot ID or use special ID 'latest'")
}
if opts.Ncdu && gopts.JSON {
return errors.Fatal("only either '--json' or '--ncdu' can be specified")
}
// extract any specific directories to walk
var dirs []string