diff options
author | Sascha <GlancingMind@outlook.com> | 2021-05-09 11:14:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 11:14:45 +0200 |
commit | 1939949fcdd5d540fd20ead79b9c5d27e85e8f9d (patch) | |
tree | a7c6889584d3a74b3aa99c05e23b05a5b1c9b7f3 /commands/bridge_configure.go | |
parent | bdb832639d9d3ddf2f7e817252eaef48c9d59d4e (diff) | |
download | git-bug-1939949fcdd5d540fd20ead79b9c5d27e85e8f9d.tar.gz |
CLI: Add non-interactive option to interactive commands (#651)
* Add option to skip the AvatarURL input request
Using an empty string for the avatar cli flag e.g. `git-bug user create
-a ""` will still result in a prompt. As the avatar URL is an optional
option, it should be possible to skip asking for it entirely.
Otherwise automated user creation via a script must make use of pipe hacks.
* Add global --non-interactive cmdline option
* Replace --skipAvatar for --non-interactive option
* Cmd BugAdd: respect non-interactive option
* Cmd bridge configure: respect non-interactive opt
* Cmd CommentAdd: respect non-interactive option
* Cmd CommentEdit: respect non-interactive option
* Cmd TermUI: respect non-interactive option
* Cmd TitleEdit: respect non-interactive option
* Remove global non-interactive option
* Cmd UserCreate: Use local non-interactive option
* Cmd BugAdd: Use local non-interactive option
* Cmd BridgeConfigure: Use local non-interactive option
* Cmd CommentAdd: Use local non-interactive option
* Cmd CommentEdit: Use local non-interactive option
* Cmd TermUI: Drop non-interactive option
It should be obviouse that the termui is an interactive command.
* Cmd TitleEdit: Use local non-interactive option
* Update docs
* Bridge GitHub: respect non-interactive option
* Bridge GitLab: respect non-interactive option
* Bridge Jira: respect non-interactive and token opt
* Fix failing compilation
* Bridge launchpad: respect non-interactive option
* bridge: isNonInteractive --> interactive
Co-authored-by: Michael Muré <batolettre@gmail.com>
Diffstat (limited to 'commands/bridge_configure.go')
-rw-r--r-- | commands/bridge_configure.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go index ecdb6502..c0ce1461 100644 --- a/commands/bridge_configure.go +++ b/commands/bridge_configure.go @@ -16,11 +16,12 @@ import ( ) type bridgeConfigureOptions struct { - name string - target string - params core.BridgeParams - token string - tokenStdin bool + name string + target string + params core.BridgeParams + token string + tokenStdin bool + nonInteractive bool } func newBridgeConfigureCommand() *cobra.Command { @@ -105,6 +106,7 @@ git bug bridge configure \ flags.BoolVar(&options.tokenStdin, "token-stdin", false, "Will read the token from stdin and ignore --token") flags.StringVarP(&options.params.Owner, "owner", "o", "", "The owner of the remote repository") flags.StringVarP(&options.params.Project, "project", "p", "", "The name of the remote repository") + flags.BoolVar(&options.nonInteractive, "non-interactive", false, "Do not ask for user input") return cmd } @@ -136,14 +138,14 @@ func runBridgeConfigure(env *Env, opts bridgeConfigureOptions) error { opts.params.TokenRaw = opts.token } - if opts.target == "" { + if !opts.nonInteractive && opts.target == "" { opts.target, err = promptTarget() if err != nil { return err } } - if opts.name == "" { + if !opts.nonInteractive && opts.name == "" { opts.name, err = promptName(env.repo) if err != nil { return err @@ -155,7 +157,7 @@ func runBridgeConfigure(env *Env, opts bridgeConfigureOptions) error { return err } - err = b.Configure(opts.params) + err = b.Configure(opts.params, !opts.nonInteractive) if err != nil { return err } |