Skip to content

Commit

Permalink
feat(ui): add smart-mode.only-print flag for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebradil committed Oct 16, 2023
1 parent 90163f5 commit 0a6349a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"time"

"github.com/logrusorgru/aurora/v4"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -57,6 +58,9 @@ func init() {
"if not provided, only local changes will be considered"
rootCmd.PersistentFlags().String("smart-mode.base-revision", "", smartModeBaseRevisionHelp)

smartModeOnlyPrintHelp := "only print the list of environments and applications that would be rendered in Smart Mode"
rootCmd.PersistentFlags().Bool("smart-mode.only-print", false, smartModeOnlyPrintHelp)

if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {
log.Fatal().Err(err).Msg("Unable to bind flags")
}
Expand Down Expand Up @@ -125,6 +129,21 @@ func detectTargetEnvsAndApps(cmd *cobra.Command, args []string) (err error) {
Interface("envAppMap", envAppMap).
Msg("Parsed arguments")

if viper.GetBool("smart-mode.only-print") {
fmt.Println(aurora.Bold("\nSmart Mode detected:"))
for env, apps := range envAppMap {
fmt.Printf("→ %s\n", env)
if apps == nil {
fmt.Println(aurora.Bold(" ALL"))
} else {
for _, app := range apps {
fmt.Printf(" %s\n", app)
}
}
}
os.Exit(0)
}

return nil
}

Expand Down

0 comments on commit 0a6349a

Please sign in to comment.