diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-06 10:42:51 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-14 21:31:45 -0600 |
commit | 058f8c36f6bf9ae2600bf7da33d680ced41eae9a (patch) | |
tree | c31b472fb024f5e046c5ed51cbeade831e0454fa /cmd/btrfs-rec/inspect_rebuildmappings.go | |
parent | f19d908439b3537cc6ae7a21eb926763e90d44ee (diff) |
cmd/btrfs-rec: Have each subcommand call runWithRawFS itself
Diffstat (limited to 'cmd/btrfs-rec/inspect_rebuildmappings.go')
-rw-r--r-- | cmd/btrfs-rec/inspect_rebuildmappings.go | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/cmd/btrfs-rec/inspect_rebuildmappings.go b/cmd/btrfs-rec/inspect_rebuildmappings.go index 005fd5d..81660b0 100644 --- a/cmd/btrfs-rec/inspect_rebuildmappings.go +++ b/cmd/btrfs-rec/inspect_rebuildmappings.go @@ -17,21 +17,19 @@ import ( ) func init() { - inspectors = append(inspectors, subcommand{ - Command: cobra.Command{ - Use: "rebuild-mappings SCAN_RESULT.json", - Short: "Rebuild broken chunk/dev-extent/blockgroup trees", - Long: "" + - "The rebuilt information is printed as JSON on stdout, and can\n" + - "be loaded by the --mappings flag.\n" + - "\n" + - "This is very similar to `btrfs rescue chunk-recover`, but (1)\n" + - "does a better job, (2) is less buggy, and (3) doesn't actually\n" + - "write the info back to the filesystem; instead writing it\n" + - "out-of-band to stdout.", - Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(1)), - }, - RunE: func(fs *btrfs.FS, cmd *cobra.Command, args []string) error { + inspectors.AddCommand(&cobra.Command{ + Use: "rebuild-mappings SCAN_RESULT.json", + Short: "Rebuild broken chunk/dev-extent/blockgroup trees", + Long: "" + + "The rebuilt information is printed as JSON on stdout, and can\n" + + "be loaded by the --mappings flag.\n" + + "\n" + + "This is very similar to `btrfs rescue chunk-recover`, but (1)\n" + + "does a better job, (2) is less buggy, and (3) doesn't actually\n" + + "write the info back to the filesystem; instead writing it\n" + + "out-of-band to stdout.", + Args: cliutil.WrapPositionalArgs(cobra.ExactArgs(1)), + RunE: runWithRawFS(func(fs *btrfs.FS, cmd *cobra.Command, args []string) error { ctx := cmd.Context() dlog.Infof(ctx, "Reading %q...", args[0]) @@ -56,6 +54,6 @@ func init() { dlog.Info(ctx, "... done writing") return nil - }, + }), }) } |