-
Notifications
You must be signed in to change notification settings - Fork 717
feat: added a default --yes flag to set the tty
#3342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ func newApp() *cobra.Command { | |
| rootCmd.PersistentFlags().Bool("debug", false, "debug mode") | ||
| // TODO: "survey" does not support using cygwin terminal on windows yet | ||
| rootCmd.PersistentFlags().Bool("tty", isatty.IsTerminal(os.Stdout.Fd()), "Enable TUI interactions such as opening an editor. Defaults to true when stdout is a terminal. Set to false for automation.") | ||
| rootCmd.PersistentFlags().BoolP("yes", "y", false, "Alias of --tty=false") | ||
| rootCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error { | ||
| l, _ := cmd.Flags().GetString("log-level") | ||
| if l != "" { | ||
|
|
@@ -129,6 +130,22 @@ func newApp() *cobra.Command { | |
| if nfs { | ||
| return errors.New("must not run on NFS dir") | ||
| } | ||
|
|
||
| if cmd.Flags().Changed("yes") && cmd.Flags().Changed("tty") { | ||
| return errors.New("cannot use both --tty and --yes flags at the same time") | ||
| } | ||
|
|
||
| if cmd.Flags().Changed("yes") { | ||
| // Sets the value of the yesValue flag by using the yes flag. | ||
| yesValue, _ := cmd.Flags().GetBool("yes") | ||
| if yesValue { | ||
| // Sets to the default value false | ||
| err := cmd.Flags().Set("tty", "false") | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting the value of |
||
| } | ||
| return nil | ||
| } | ||
| rootCmd.AddGroup(&cobra.Group{ID: "basic", Title: "Basic Commands:"}) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.