aboutsummaryrefslogtreecommitdiffstats
path: root/commands/comment_edit.go
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-05-09 11:14:45 +0200
committerGitHub <noreply@github.com>2021-05-09 11:14:45 +0200
commit1939949fcdd5d540fd20ead79b9c5d27e85e8f9d (patch)
treea7c6889584d3a74b3aa99c05e23b05a5b1c9b7f3 /commands/comment_edit.go
parentbdb832639d9d3ddf2f7e817252eaef48c9d59d4e (diff)
downloadgit-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/comment_edit.go')
-rw-r--r--commands/comment_edit.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/commands/comment_edit.go b/commands/comment_edit.go
index 6a86f37e..6c93ed8b 100644
--- a/commands/comment_edit.go
+++ b/commands/comment_edit.go
@@ -7,8 +7,9 @@ import (
)
type commentEditOptions struct {
- messageFile string
- message string
+ messageFile string
+ message string
+ nonInteractive bool
}
func newCommentEditCommand() *cobra.Command {
@@ -34,6 +35,7 @@ func newCommentEditCommand() *cobra.Command {
flags.StringVarP(&options.message, "message", "m", "",
"Provide the new message from the command line")
+ flags.BoolVar(&options.nonInteractive, "non-interactive", false, "Do not ask for user input")
return cmd
}
@@ -52,6 +54,10 @@ func runCommentEdit(env *Env, opts commentEditOptions, args []string) error {
}
if opts.messageFile == "" && opts.message == "" {
+ if opts.nonInteractive {
+ env.err.Println("No message given. Use -m or -F option to specify a message. Aborting.")
+ return nil
+ }
opts.message, err = input.BugCommentEditorInput(env.backend, "")
if err == input.ErrEmptyMessage {
env.err.Println("Empty message, aborting.")