Skip to content

Commit

Permalink
output improvement
Browse files Browse the repository at this point in the history
Signed-off-by: Tullio Sebastiani <[email protected]>
  • Loading branch information
tsebastiani committed Dec 13, 2024
1 parent 293537b commit b350af6
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,39 @@ func NewRunCommand(factory *factory.ProviderFactory, scenarioOrchestrator *scena
cmd.LocalFlags().AddFlagSet(scenarioFlags)

cmd.SetHelpFunc(func(command *cobra.Command, args []string) {
fmt.Println("Krkn global flags:")
globalFlags.VisitAll(func(f *pflag.Flag) {
fmt.Printf(" --%s: %s\n", f.Name, f.Usage)
})

fmt.Println(fmt.Sprintf("\n%s Flags:", scenarioDetail.Name))
scenarioFlags.VisitAll(func(f *pflag.Flag) {
fmt.Printf(" --%s: %s\n", f.Name, f.Usage)
})
yellow := color.New(color.FgYellow).SprintFunc()
green := color.New(color.FgGreen).SprintFunc()
boldGreen := color.New(color.FgHiGreen, color.Bold).SprintFunc()

fmt.Println(fmt.Sprintf("%s", yellow("Krkn Global flags")))
for _, f := range globalEnvDetail.Fields {
if f.Default != nil && *f.Default != "" {
fmt.Printf(" --%s (%s): %s (Default: %s)\n", *f.Name, f.Type.String(), *f.Description, *f.Default)
} else {
fmt.Printf(" --%s (%s): %s\n", *f.Name, f.Type.String(), *f.Description)
}

}

fmt.Println(fmt.Sprintf("\n%s %s", boldGreen(scenarioDetail.Name), green("Flags")))
for _, f := range scenarioDetail.Fields {
if f.Default != nil && *f.Default != "" {
fmt.Printf(" --%s (%s): %s (Default: %s)\n", *f.Name, f.Type.String(), *f.Description, *f.Default)
} else {
fmt.Printf(" --%s (%s): %s\n", *f.Name, f.Type.String(), *f.Description)
}

}

fmt.Print("\n\n")

})

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
(*scenarioOrchestrator).PrintContainerRuntime()
spinner := NewSpinnerWithSuffix("validating input...")
spinner := NewSpinnerWithSuffix("fetching scenario metadata...")

// Starts validating input message
spinner.Start()
Expand Down Expand Up @@ -184,6 +200,7 @@ func NewRunCommand(factory *factory.ProviderFactory, scenarioOrchestrator *scena
if alertsProfile != nil {
volumes[*alertsProfile] = config.AlertsProfilePath
}
spinner.Suffix = "validating input ..."
//dynamic flags parsing
scenarioEnv, scenarioVol, err := ParseFlags(scenarioDetail, args, scenarioCollectedFlags, false)
if err != nil {
Expand Down

0 comments on commit b350af6

Please sign in to comment.