summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-07 01:45:05 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-14 21:31:45 -0600
commit7c9ea276ac69130229f4ae35547288fe8429f6f1 (patch)
treec6efc38a1b11ddeecf2c51d3e6bde5cc063c8164
parent058f8c36f6bf9ae2600bf7da33d680ced41eae9a (diff)
cmd/btrfs-rec: Don't require --pv for `help`
-rw-r--r--cmd/btrfs-rec/main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/btrfs-rec/main.go b/cmd/btrfs-rec/main.go
index 5da8f52..343a41f 100644
--- a/cmd/btrfs-rec/main.go
+++ b/cmd/btrfs-rec/main.go
@@ -86,7 +86,6 @@ func main() {
argparser.PersistentFlags().StringArrayVar(&globalFlags.pvs, "pv", nil, "open the file `physical_volume` as part of the filesystem")
noError(argparser.MarkPersistentFlagFilename("pv"))
- noError(argparser.MarkPersistentFlagRequired("pv"))
argparser.PersistentFlags().StringVar(&globalFlags.mappings, "mappings", "", "load chunk/dev-extent/blockgroup data from external JSON file `mappings.json`")
noError(argparser.MarkPersistentFlagFilename("mappings"))
@@ -130,6 +129,11 @@ func runWithRawFS(runE func(*btrfs.FS, *cobra.Command, []string) error) func(*co
defer func() {
maybeSetErr(globalFlags.stopProfiling())
}()
+ if len(globalFlags.pvs) == 0 {
+ // We do this here instead of calling argparser.MarkPersistentFlagRequired("pv") so that
+ // it doesn't interfere with the `help` sub-command.
+ return cliutil.FlagErrorFunc(cmd, fmt.Errorf("must specify 1 or more physical volumes with --pv"))
+ }
fs, err := btrfsutil.Open(ctx, globalFlags.openFlag, globalFlags.pvs...)
if err != nil {
return err