Skip to content

Commit 69f4ed7

Browse files
committed
remove run as subcommand - it's the default action
1 parent ffa3a40 commit 69f4ed7

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

cmd/repomon/main.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,25 @@ func main() {
9393
rmOpts := &rmOptions{}
9494
runner := newDefaultRunner(os.Stdout, os.Stderr, os.Stdin)
9595

96-
var runCmd = &cobra.Command{
97-
Use: "run",
98-
Short: "Monitors configured git repositories and reports recent changes",
96+
var rootCmd = &cobra.Command{
97+
Use: "repomon",
98+
Short: "A tool to monitor git repositories and report recent changes",
99+
Long: `Repomon monitors configured git repositories and generates a report
100+
showing the most recent commits to each repository in an easy-to-read format.`,
99101
Run: func(cmd *cobra.Command, args []string) {
100102
if err := runner.executeRun(cmd.Context(), args, runOpts, rootOpts); err != nil {
101103
slog.Error("Run command failed", "error", err)
102104
os.Exit(1)
103105
}
104106
},
105107
}
106-
// Bind run-specific flags to runOptions
107-
runCmd.Flags().IntVarP(&runOpts.days, "days", "d", 1, "number of days to look back in history")
108-
runCmd.Flags().BoolVar(&runOpts.debug, "debug", false, "enable debug logging")
109-
110-
var rootCmd = &cobra.Command{
111-
Use: "repomon",
112-
Short: "A tool to monitor git repositories and report recent changes",
113-
Long: `Repomon monitors configured git repositories and generates a report
114-
showing the most recent commits to each repository in an easy-to-read format.`,
115-
Run: runCmd.Run, // Set runCmd.Run as the default action for rootCmd
116-
}
117108

118109
// Bind persistent flags to rootOptions
119110
rootCmd.PersistentFlags().StringVarP(&rootOpts.configFile, "config", "c", "", "path to config file (default ~/.config/repomon/config.yaml)")
120111
rootCmd.PersistentFlags().StringVarP(&rootOpts.group, "group", "g", "", "repository group to use (default: 'default')")
121-
// Add run-specific flags to rootCmd so they work without 'run' subcommand
122-
rootCmd.Flags().AddFlagSet(runCmd.Flags())
112+
// Bind run-specific flags to runOptions
113+
rootCmd.Flags().IntVarP(&runOpts.days, "days", "d", 1, "number of days to look back in history")
114+
rootCmd.Flags().BoolVar(&runOpts.debug, "debug", false, "enable debug logging")
123115

124116
var versionCmd = &cobra.Command{
125117
Use: "version",
@@ -151,7 +143,6 @@ showing the most recent commits to each repository in an easy-to-read format.`,
151143
},
152144
}
153145

154-
rootCmd.AddCommand(runCmd)
155146
rootCmd.AddCommand(listCmd)
156147
rootCmd.AddCommand(versionCmd)
157148

0 commit comments

Comments
 (0)