Recursive handling for command line flags

Every struct in a NodeConf with `lopt:"foo" set is now added as a
command-line flag with the RecursiveCreateFlags call. For maps a struct
with the key UNDEF is added so that it can be parsed out.

As the flags for the command-line need variables which hold the values,
for every map an element map[UNDEF] is added.  When now calling the
internal add, these map element can be filtered out and replace by the
given name. (e.g., --netname)

* rewrote node/profile add for recursive functions
* rewrote node/profile set for recursive functions
* rewrote node/profile list for recursive functions

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-08-11 10:31:29 -06:00
committed by Jonathon Anderson
parent c55c5a2ac4
commit 45539a0d1f
29 changed files with 1346 additions and 714 deletions

View File

@@ -16,8 +16,9 @@ func CobraRunE(vars *variables) func(cmd *cobra.Command, args []string) (err err
args = strings.FieldsFunc(args[0], func(r rune) bool { return r == ',' })
}
req := wwapiv1.GetProfileList{
ShowAll: vars.showAll,
Profiles: args,
ShowAll: vars.showAll,
ShowFullAll: vars.showFullAll,
Profiles: args,
}
profileInfo, err := apiprofile.ProfileList(&req)
if err != nil {

View File

@@ -3,7 +3,8 @@ package list
import "github.com/spf13/cobra"
type variables struct {
showAll bool
showAll bool
showFullAll bool
}
// GetRootCommand returns the root cobra.Command for the application.
@@ -17,7 +18,8 @@ func GetCommand() *cobra.Command {
RunE: CobraRunE(&vars),
Aliases: []string{"ls"},
}
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all node configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showAll, "all", "a", false, "Show all profile configurations")
baseCmd.PersistentFlags().BoolVarP(&vars.showFullAll, "fullall", "A", false, "Show all profile configurations inclusive empty entries")
return baseCmd
}