Skip to content

Commit

Permalink
add no-color flag to tfrobot
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Nov 5, 2024
1 parent 2c763e1 commit 4f0a1ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tfrobot/cmd/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var cancelCmd = &cobra.Command{
return err
}

tfPluginClient, err := setup(cfg, debug)
tfPluginClient, err := setup(cfg, debug, false)
if err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion tfrobot/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var deployCmd = &cobra.Command{
if err != nil {
return errors.Wrap(err, "error in output file")
}
noColor, err := cmd.Flags().GetBool("no-color")
if err != nil {
return err
}

if err = checkOutputFile(outputPath); err != nil {
return err
Expand All @@ -41,7 +45,7 @@ var deployCmd = &cobra.Command{
return err
}

tfPluginClient, err := setup(cfg, debug)
tfPluginClient, err := setup(cfg, debug, noColor)
if err != nil {
return err
}
Expand All @@ -64,4 +68,5 @@ func init() {
deployCmd.Flags().BoolP("debug", "d", false, "allow debug logs")
deployCmd.Flags().StringP("config", "c", "", "path to config file")
deployCmd.Flags().StringP("output", "o", "output.yaml", "path to output file")
deployCmd.Flags().Bool("no-color", false, "disable output styling")
}
7 changes: 6 additions & 1 deletion tfrobot/cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var loadCmd = &cobra.Command{
if err != nil {
return errors.Wrap(err, "error in output file")
}
noColor, err := cmd.Flags().GetBool("no-color")
if err != nil {
return err
}

if err = checkOutputFile(outputPath); err != nil {
return err
Expand All @@ -41,7 +45,7 @@ var loadCmd = &cobra.Command{
return err
}

tfPluginClient, err := setup(cfg, debug)
tfPluginClient, err := setup(cfg, debug, noColor)
if err != nil {
return err
}
Expand All @@ -60,4 +64,5 @@ func init() {
loadCmd.Flags().BoolP("debug", "d", false, "allow debug logs")
loadCmd.Flags().StringP("config", "c", "", "path to config file")
loadCmd.Flags().StringP("output", "o", "output.yaml", "path to output file")
loadCmd.Flags().Bool("no-color", false, "disable output styling")
}
6 changes: 5 additions & 1 deletion tfrobot/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsonExt = ".json"

var allowedExt = []string{".yml", ".yaml", jsonExt}

func setup(conf tfrobot.Config, debug bool) (deployer.TFPluginClient, error) {
func setup(conf tfrobot.Config, debug, noColor bool) (deployer.TFPluginClient, error) {
network := conf.Network
log.Debug().Str("network", network).Send()

Expand All @@ -30,9 +30,13 @@ func setup(conf tfrobot.Config, debug bool) (deployer.TFPluginClient, error) {
deployer.WithRMBTimeout(30),
deployer.WithNetwork(network),
}

if debug {
opts = append(opts, deployer.WithLogs())
}
if noColor {
opts = append(opts, deployer.WithNoColorLogs())
}

return deployer.NewTFPluginClient(mnemonic, opts...)
}
Expand Down
2 changes: 1 addition & 1 deletion tfrobot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/go-playground/validator/v10 v10.17.0
github.com/hashicorp/go-multierror v1.1.1
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/sethvargo/go-retry v0.3.0
github.com/spf13/cobra v1.8.1
Expand Down Expand Up @@ -52,7 +53,6 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down

0 comments on commit 4f0a1ac

Please sign in to comment.