Skip to content

Commit

Permalink
Fix verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Nov 22, 2022
1 parent f45a5db commit 0a61b50
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ build-frontend:

.PHONY: serve-backend
serve-backend:
air --build.cmd "go build -o ./tmp/$(bin) ." --build.bin "$(build_bin)" --build.exclude_dir "assets,docs,tmp,web,scripts,ssh-key,.github,.git" --build.include_ext "go,yaml,html,js" --build.exclude_file "config.example.yaml" --build.args_bin "dashboard,--config,config-test.yaml" --build.stop_on_error true --misc.clean_on_exit true --log.time true
air --build.cmd "go build -o ./tmp/$(bin) ." --build.bin "$(build_bin)" --build.exclude_dir "assets,docs,tmp,web,scripts,ssh-key,.github,.git" --build.include_ext "go,yaml,html,js" --build.exclude_file "config.example.yaml" --build.args_bin "dashboard,--config,config-test.yaml,--verbose" --build.stop_on_error true --misc.clean_on_exit true --log.time true

app: build-frontend serve-backend
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For personal usage, install latest from [Github Releases](https://github.com/bis

```bash
# binary is downloaded and named as saido
saido dashboard --config config.yaml --port 3000
saido dashboard --config config.yaml --port 3000 --verbose
```


Expand Down
6 changes: 6 additions & 0 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ var apiCmd = &cobra.Command{
Short: "Run saido dashboard on a PORT env variable, fallback to set argument",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if verbose {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
cfg = config.LoadConfig(cfgFile)
hosts := client.NewHostsController(cfg)

Expand All @@ -98,6 +103,7 @@ var apiCmd = &cobra.Command{

func init() {
apiCmd.Flags().StringVarP(&port, "port", "p", "3000", "Port to run application server on")
apiCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Run saido in verbose mode")
apiCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Path to config file")
cobra.MarkFlagRequired(apiCmd.PersistentFlags(), "config")
rootCmd.AddCommand(apiCmd)
Expand Down
9 changes: 0 additions & 9 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ var rootCmd = &cobra.Command{
Long: ``,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Log only errors except in Verbose mode
if verbose {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
fmt.Println("\n\nSaido - Bisohns (2020) (https://github.com/bisohns/saido)")
Expand All @@ -62,7 +57,3 @@ func Execute() {
os.Exit(1)
}
}

func init() {
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Run saido in verbose mode")
}

0 comments on commit 0a61b50

Please sign in to comment.