Choose fields to display with -o flag
This commit is contained in:
21
cmd/root.go
21
cmd/root.go
@ -14,11 +14,13 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
gJails []Jail
|
||||
gJails []Jail
|
||||
|
||||
gUseSudo bool
|
||||
gUseSudo bool
|
||||
|
||||
gConfigFile string
|
||||
gDisplayColumns string
|
||||
|
||||
gConfigFile string
|
||||
|
||||
rootCmd = & cobra.Command{
|
||||
Use: "gocage",
|
||||
@ -73,8 +75,8 @@ func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&gUseSudo, "sudo", "s", false, "Use sudo to run commands")
|
||||
|
||||
// Command dependant switches
|
||||
/* listComputerCmd.PersistentFlags().BoolVarP(&gDisplayAsCSV, "csv-format", "v", false, "Show results in CSV (separator = ';')")
|
||||
searchComputerCmd.PersistentFlags().BoolVarP(&gShowAccount, "show-account", "c", false, "Show account when listing computer")
|
||||
listCmd.PersistentFlags().StringVarP(&gDisplayColumns, "outcol", "o", "JID,Name,Config.Release,Config.Ip4_addr,Running", "Show these columns in output")
|
||||
/* 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 = ';')")
|
||||
*/
|
||||
|
||||
@ -102,7 +104,14 @@ func initConfig() {
|
||||
// fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
// fmt.Printf("datastore in config : %s\n", viper.GetStringSlice("datastore"))
|
||||
// fmt.Printf("datastore.0 in config : %s\n", viper.GetStringSlice("datastore.0"))
|
||||
gUseSudo = viper.GetBool("sudo")
|
||||
|
||||
// Command line flags have priority on config file
|
||||
if false == rootCmd.Flags().Lookup("sudo").Changed {
|
||||
gUseSudo = viper.GetBool("sudo")
|
||||
}
|
||||
if false == listCmd.Flags().Lookup("outcol").Changed {
|
||||
gDisplayColumns = viper.GetString("outcol")
|
||||
}
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
||||
Reference in New Issue
Block a user