Skip to content

Commit c7ac23d

Browse files
committed
allow specific uploader to be chosen for clean
1 parent a565313 commit c7ac23d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cmd/clean.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"github.com/pkg/errors"
77
"github.com/spf13/cobra"
88
"github.com/yale8848/gorpool"
9+
"strings"
910
)
1011

1112
var cleanCmd = &cobra.Command{
12-
Use: "clean [UPLOADER]",
13-
Short: "Perform uploader clean",
14-
Long: `This command can be used to trigger an uploader clean.`,
13+
Use: "clean",
14+
Short: "Perform cleans associated to uploader(s)",
15+
Long: `This command can be used to trigger a clean associated with uploader(s).`,
1516

16-
Args: cobra.ExactArgs(1),
1717
Run: func(cmd *cobra.Command, args []string) {
1818
// init core
1919
initCore(true)
@@ -26,6 +26,13 @@ var cleanCmd = &cobra.Command{
2626
continue
2727
}
2828

29+
// skip uploader specific chosen
30+
if flagUploader != "" && !strings.EqualFold(uploaderName, flagUploader) {
31+
log.WithField("uploader", uploaderName).Tracef("Skipping uploader as not: %q",
32+
flagUploader)
33+
continue
34+
}
35+
2936
log := log.WithField("uploader", uploaderName)
3037

3138
// create uploader
@@ -49,6 +56,8 @@ var cleanCmd = &cobra.Command{
4956

5057
func init() {
5158
rootCmd.AddCommand(cleanCmd)
59+
60+
cleanCmd.Flags().StringVarP(&flagUploader, "uploader", "u", "", "Run for a specific uploader.")
5261
}
5362

5463
func performClean(u *uploader.Uploader) error {

cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var (
2525

2626
flagDryRun bool
2727

28+
// Global command specific
29+
flagUploader string
30+
2831
// Global vars
2932
log *logrus.Entry
3033
)

0 commit comments

Comments
 (0)