()
| 18 | } |
| 19 | |
| 20 | func newCompactCommand() *cobra.Command { |
| 21 | var o compactOptions |
| 22 | var compactCmd = &cobra.Command{ |
| 23 | Use: "compact [options] -o <dst-bbolt-file> <src-bbolt-file>", |
| 24 | Short: "creates a compacted copy of the database from source path to the destination path, preserving the original.", |
| 25 | Long: `compact opens a database at source path and walks it recursively, copying keys |
| 26 | as they are found from all buckets, to a newly created database at the destination path. |
| 27 | The original database is left untouched.`, |
| 28 | Args: cobra.MinimumNArgs(1), |
| 29 | RunE: func(cmd *cobra.Command, args []string) error { |
| 30 | if err := o.Validate(args[0]); err != nil { |
| 31 | return err |
| 32 | } |
| 33 | return o.Run(cmd, args[0]) |
| 34 | }, |
| 35 | } |
| 36 | o.AddFlags(compactCmd.Flags()) |
| 37 | |
| 38 | return compactCmd |
| 39 | } |
| 40 | |
| 41 | func (o *compactOptions) AddFlags(fs *pflag.FlagSet) { |
| 42 | fs.StringVarP(&o.dstPath, "output", "o", "", "") |
no test coverage detected