| 8 | ) |
| 9 | |
| 10 | func pkgShowTagCmd() *cobra.Command { |
| 11 | var canonical bool |
| 12 | cmd := &cobra.Command{ |
| 13 | Use: "show-tag", |
| 14 | Short: "show the tag for packages based on its source directory", |
| 15 | Long: `Show the tag for one or more packages based on their source directories. |
| 16 | 'path' specifies the path to the package source directory. |
| 17 | `, |
| 18 | Args: cobra.MinimumNArgs(1), |
| 19 | Example: "linuxkit pkg show-tag path/to/package [path/to/another/package] [path/to/yet/another/package]", |
| 20 | RunE: func(cmd *cobra.Command, args []string) error { |
| 21 | pkgs, err := pkglib.NewFromConfig(pkglibConfig, args...) |
| 22 | if err != nil { |
| 23 | return err |
| 24 | } |
| 25 | for _, p := range pkgs { |
| 26 | tag := p.Tag() |
| 27 | if canonical { |
| 28 | tag = p.FullTag() |
| 29 | } |
| 30 | fmt.Println(tag) |
| 31 | } |
| 32 | return nil |
| 33 | }, |
| 34 | } |
| 35 | cmd.Flags().BoolVar(&canonical, "canonical", false, "Show canonical name, e.g. docker.io/linuxkit/foo:1234, instead of the default, e.g. linuxkit/foo:1234") |
| 36 | |
| 37 | return cmd |
| 38 | } |