Skip to content

Commit

Permalink
Restricting config outside version
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Jan 6, 2023
1 parent a547afc commit 9955ac2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var rootCmd = &cobra.Command{
} else {
log.SetLevel(log.InfoLevel)
}
fmt.Println(args)
cfg = config.LoadConfig(cfgFile)
hosts := client.NewHostsController(cfg)

Expand Down Expand Up @@ -96,5 +97,7 @@ func init() {
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Run saido in verbose mode")
rootCmd.Flags().BoolVarP(&browserFlag, "open-browser", "b", false, "Prompt open browser")
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Path to config file")
cobra.MarkFlagRequired(rootCmd.PersistentFlags(), "config")
if len(os.Args) >= 2 && os.Args[1] != "version" || len(os.Args) == 1 {
cobra.MarkFlagRequired(rootCmd.PersistentFlags(), "config")
}
}

0 comments on commit 9955ac2

Please sign in to comment.