|
15 | 15 | package cmd |
16 | 16 |
|
17 | 17 | import ( |
18 | | - "github.com/spf13/cobra" |
19 | | - |
20 | 18 | "github.com/labring/sealos/pkg/utils/archive" |
21 | 19 | "github.com/labring/sealos/pkg/utils/flags" |
| 20 | + "github.com/spf13/cobra" |
22 | 21 | ) |
23 | 22 |
|
24 | 23 | func newTarCmd() *cobra.Command { |
25 | 24 | var ( |
26 | 25 | compressionF flags.Compression |
27 | 26 | output string |
28 | | - clear bool |
| 27 | + clearSource bool |
29 | 28 | ) |
30 | 29 | cmd := &cobra.Command{ |
31 | 30 | Use: "tar", |
32 | 31 | Short: "creates an archive file from the directory at `path`, note that this will strip the parent dir", |
33 | 32 | Args: cobra.ExactArgs(1), |
34 | 33 | SilenceErrors: true, |
35 | 34 | RunE: func(cmd *cobra.Command, args []string) error { |
36 | | - return archive.Tar(args[0], output, compressionF, clear) |
| 35 | + return archive.Tar(args[0], output, compressionF, clearSource) |
37 | 36 | }, |
38 | 37 | } |
39 | | - cmd.Flags().Var(&compressionF, "compression", "compression algorithm, available options are tar/gzip/zstd/disable") |
| 38 | + cmd.Flags(). |
| 39 | + Var(&compressionF, "compression", "compression algorithm, available options are tar/gzip/zstd/disable") |
40 | 40 | cmd.Flags().StringVarP(&output, "output", "o", "", "path of archive file") |
41 | | - cmd.Flags().BoolVar(&clear, "clear", false, "remove source after compression finished") |
| 41 | + cmd.Flags().BoolVar(&clearSource, "clear", false, "remove source after compression finished") |
42 | 42 | _ = cmd.MarkFlagRequired("output") |
43 | 43 | _ = cmd.MarkFlagRequired("compression") |
44 | 44 | return cmd |
45 | 45 | } |
46 | 46 |
|
47 | 47 | func newUntarCmd() *cobra.Command { |
48 | 48 | var ( |
49 | | - clear bool |
50 | | - output string |
| 49 | + clearSource bool |
| 50 | + output string |
51 | 51 | ) |
52 | 52 | cmd := &cobra.Command{ |
53 | 53 | Use: "untar", |
54 | 54 | Short: "looks for archive files match glob patterns at filesystem path `src`, and unpacks it at `dst`", |
55 | 55 | Args: cobra.MinimumNArgs(1), |
56 | 56 | SilenceErrors: true, |
57 | 57 | RunE: func(cmd *cobra.Command, args []string) error { |
58 | | - return archive.Untar(args, output, clear) |
| 58 | + return archive.Untar(args, output, clearSource) |
59 | 59 | }, |
60 | 60 | } |
61 | 61 | cmd.Flags().StringVarP(&output, "output", "o", "", "path to uncompress archive files") |
62 | | - cmd.Flags().BoolVar(&clear, "clear", false, "remove source after uncompression finished") |
| 62 | + cmd.Flags().BoolVar(&clearSource, "clear", false, "remove source after uncompression finished") |
63 | 63 | _ = cmd.MarkFlagRequired("output") |
64 | 64 | return cmd |
65 | 65 | } |
|
0 commit comments