From 058f8c36f6bf9ae2600bf7da33d680ced41eae9a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 6 Mar 2023 10:42:51 -0700 Subject: cmd/btrfs-rec: Have each subcommand call runWithRawFS itself --- cmd/btrfs-rec/inspect_mount.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'cmd/btrfs-rec/inspect_mount.go') diff --git a/cmd/btrfs-rec/inspect_mount.go b/cmd/btrfs-rec/inspect_mount.go index f3fda34..4582f9f 100644 --- a/cmd/btrfs-rec/inspect_mount.go +++ b/cmd/btrfs-rec/inspect_mount.go @@ -14,17 +14,16 @@ import ( func init() { var skipFileSums bool - cmd := subcommand{ - Command: cobra.Command{ - Use: "mount MOUNTPOINT", - Short: "Mount the filesystem read-only", - Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(1)), - }, - RunE: func(fs *btrfs.FS, cmd *cobra.Command, args []string) error { + cmd := &cobra.Command{ + Use: "mount MOUNTPOINT", + Short: "Mount the filesystem read-only", + Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(1)), + RunE: runWithRawFS(func(fs *btrfs.FS, cmd *cobra.Command, args []string) error { return mount.MountRO(cmd.Context(), fs, args[0], skipFileSums) - }, + }), } - cmd.Command.Flags().BoolVar(&skipFileSums, "skip-filesums", false, + cmd.Flags().BoolVar(&skipFileSums, "skip-filesums", false, "ignore checksum failures on file contents; allow such files to be read") - inspectors = append(inspectors, cmd) + + inspectors.AddCommand(cmd) } -- cgit v1.2.3-2-g168b