Skip to content

Commit

Permalink
minor restructure to root flags
Browse files Browse the repository at this point in the history
  • Loading branch information
zackbradys committed Nov 8, 2024
1 parent a3e2554 commit 7b20d14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/hauler/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func New() *cobra.Command {
},
}

pf := cmd.PersistentFlags()
pf.StringVarP(&ro.LogLevel, "log-level", "l", "info", "")
flags.AddRootFlags(cmd, ro)

// Add subcommands
addLogin(cmd)
Expand Down
7 changes: 7 additions & 0 deletions internal/flags/cli.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package flags

import "github.com/spf13/cobra"

type CliRootOpts struct {
LogLevel string
}

func AddRootFlags(cmd *cobra.Command, ro *CliRootOpts) {
pf := cmd.PersistentFlags()
pf.StringVarP(&ro.LogLevel, "log-level", "l", "info", "Set the logging level (i.e. info, debug, warn)")
}

0 comments on commit 7b20d14

Please sign in to comment.