Skip to content

Commit

Permalink
CLI: Expose --plain-ui to be used in environment that has no /dev/t…
Browse files Browse the repository at this point in the history
…ty (#423)
  • Loading branch information
magodo authored Jul 10, 2023
1 parent d581f46 commit ebf167e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 4 additions & 1 deletion flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ type FlagSet struct {
flagParallelism int
flagContinue bool
flagNonInteractive bool
flagPlainUI bool
flagGenerateMappingFile bool
flagHCLOnly bool
flagModulePath string

// common flags (hidden)
hflagMockClient bool
hflagPlainUI bool
hflagProfile string
hflagTFClientPluginPath string

Expand Down Expand Up @@ -108,6 +108,9 @@ func (flag FlagSet) DescribeCLI(mode string) string {
if flag.flagNonInteractive {
args = append(args, "--non-interactive=true")
}
if flag.flagPlainUI {
args = append(args, "--plain-ui=true")
}
if flag.flagContinue {
args = append(args, "--continue=true")
}
Expand Down
21 changes: 10 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ func main() {
Usage: "Non-interactive mode",
Destination: &flagset.flagNonInteractive,
},
&cli.BoolFlag{
Name: "plain-ui",
EnvVars: []string{"AZTFEXPORT_PLAIN_UI"},
Usage: "In non-interactive mode, print the progress information line by line, rather than the spinner UI. This can be used in OS that has no /dev/tty available",
Destination: &flagset.flagPlainUI,
},
&cli.BoolFlag{
Name: "continue",
EnvVars: []string{"AZTFEXPORT_CONTINUE"},
Expand Down Expand Up @@ -261,13 +267,6 @@ func main() {
Hidden: true,
Destination: &flagset.hflagMockClient,
},
&cli.BoolFlag{
Name: "plain-ui",
EnvVars: []string{"AZTFEXPORT_PLAIN_UI"},
Usage: "In non-interactive mode, print the progress information line by line, rather than the spinner UI",
Hidden: true,
Destination: &flagset.hflagPlainUI,
},
&cli.StringFlag{
Name: "profile",
EnvVars: []string{"AZTFEXPORT_PROFILE"},
Expand Down Expand Up @@ -459,7 +458,7 @@ func main() {
cfg.CommonConfig.TFClient = tfc
}

return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.hflagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeResource))
return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.flagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeResource))
},
},
{
Expand Down Expand Up @@ -523,7 +522,7 @@ func main() {
cfg.CommonConfig.TFClient = tfc
}

return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.hflagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeResourceGroup))
return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.flagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeResourceGroup))
},
},
{
Expand Down Expand Up @@ -586,7 +585,7 @@ func main() {
cfg.CommonConfig.TFClient = tfc
}

return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.hflagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeQuery))
return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.flagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeQuery))
},
},
{
Expand Down Expand Up @@ -648,7 +647,7 @@ func main() {
cfg.CommonConfig.TFClient = tfc
}

return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.hflagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeMappingFile))
return realMain(c.Context, cfg, flagset.flagNonInteractive, flagset.hflagMockClient, flagset.flagPlainUI, flagset.flagGenerateMappingFile, flagset.hflagProfile, flagset.DescribeCLI(ModeMappingFile))
},
},
},
Expand Down

0 comments on commit ebf167e

Please sign in to comment.