BUGFIX null pointer when flags not used
This commit is contained in:
parent
304a7bb253
commit
eceb108f2c
@ -78,9 +78,6 @@ func init() {
|
||||
// Command dependant switches
|
||||
listCmd.PersistentFlags().StringVarP(&gDisplayColumns, "outcol", "o", "JID,Name,Config.Release,Config.Ip4_addr,Running", "Show these columns in output")
|
||||
listCmd.PersistentFlags().BoolVarP(&gNoLineSep, "nolinesep", "l", false, "Do not display line separator between jails")
|
||||
/* searchComputerCmd.PersistentFlags().BoolVarP(&gShowAccount, "show-account", "c", false, "Show account when listing computer")
|
||||
searchComputerCmd.PersistentFlags().BoolVarP(&gDisplayAsCSV, "csv-format", "v", false, "Show results in CSV (separator = ';')")
|
||||
*/
|
||||
|
||||
// Now declare commands
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
@ -108,13 +105,13 @@ func initConfig() {
|
||||
// fmt.Printf("datastore.0 in config : %s\n", viper.GetStringSlice("datastore.0"))
|
||||
|
||||
// Command line flags have priority on config file
|
||||
if false == rootCmd.Flags().Lookup("sudo").Changed {
|
||||
if rootCmd.Flags().Lookup("sudo") != nil && false == rootCmd.Flags().Lookup("sudo").Changed {
|
||||
gUseSudo = viper.GetBool("sudo")
|
||||
}
|
||||
if false == listCmd.Flags().Lookup("outcol").Changed {
|
||||
if listCmd.Flags().Lookup("outcol") != nil && false == listCmd.Flags().Lookup("outcol").Changed {
|
||||
gDisplayColumns = viper.GetString("outcol")
|
||||
}
|
||||
if false == listCmd.Flags().Lookup("nolinesep").Changed {
|
||||
if listCmd.Flags().Lookup("nolinesep") != nil && false == listCmd.Flags().Lookup("nolinesep").Changed {
|
||||
gNoLineSep = viper.GetBool("nolinesep")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user