Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func init() {
RootCmd.AddCommand(tagCmd)

tagCmd.Flags().BoolVarP(&list, "list", "l", false, "list tags in repositories with optional pattern")
tagCmd.Flags().BoolVarP(&del, "delete", "d", false, "delete tags in repositories")

tagCmd.MarkFlagsMutuallyExclusive("list", "delete")
}

var tagCmd = &cobra.Command{
Expand All @@ -32,11 +35,6 @@ func tagFunc(cmd *cobra.Command, args []string) error {
verbose := viper.GetBool("verbose")
ctx := client.WithVerbose(context.Background(), verbose)

if !verbose {
uiprogress.Start()
defer uiprogress.Stop()
}

repoDirs, err := clt.GetDirs(ctx, dir)
if err != nil {
cmd.SilenceUsage = true
Expand All @@ -55,6 +53,20 @@ func tagFunc(cmd *cobra.Command, args []string) error {
return nil
}

if del {
if len(args) == 0 {
cmd.SilenceUsage = true
return fmt.Errorf("tag name is required when deleting a tag")
}

if !verbose {
uiprogress.Start()
defer uiprogress.Stop()
}

args = append([]string{"--delete"}, args[0])
}

err = clt.TagRepos(ctx, repoDirs, args...)
if err != nil {
cmd.SilenceUsage = true
Expand Down
Loading