diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/add.go | 10 | ||||
-rw-r--r-- | commands/bridge_configure.go | 18 | ||||
-rw-r--r-- | commands/comment_add.go | 10 | ||||
-rw-r--r-- | commands/comment_edit.go | 10 | ||||
-rw-r--r-- | commands/title_edit.go | 8 | ||||
-rw-r--r-- | commands/user_create.go | 14 |
6 files changed, 47 insertions, 23 deletions
diff --git a/commands/add.go b/commands/add.go index ad3b164b..3a28c424 100644 --- a/commands/add.go +++ b/commands/add.go @@ -8,9 +8,10 @@ import ( ) type addOptions struct { - title string - message string - messageFile string + title string + message string + messageFile string + nonInteractive bool } func newAddCommand() *cobra.Command { @@ -36,6 +37,7 @@ func newAddCommand() *cobra.Command { "Provide a message to describe the issue") flags.StringVarP(&options.messageFile, "file", "F", "", "Take the message from the given file. Use - to read the message from the standard input") + flags.BoolVar(&options.nonInteractive, "non-interactive", false, "Do not ask for user input") return cmd } @@ -49,7 +51,7 @@ func runAdd(env *Env, opts addOptions) error { } } - if opts.messageFile == "" && (opts.message == "" || opts.title == "") { + if !opts.nonInteractive && opts.messageFile == "" && (opts.message == "" || opts.title == "") { opts.title, opts.message, err = input.BugCreateEditorInput(env.backend, opts.title, opts.message) if err == input.ErrEmptyTitle { 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 } diff --git a/commands/comment_add.go b/commands/comment_add.go index 438e983a..54c75702 100644 --- a/commands/comment_add.go +++ b/commands/comment_add.go @@ -9,8 +9,9 @@ import ( ) type commentAddOptions struct { - messageFile string - message string + messageFile string + message string + nonInteractive bool } func newCommentAddCommand() *cobra.Command { @@ -35,6 +36,7 @@ func newCommentAddCommand() *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 } @@ -53,6 +55,10 @@ func runCommentAdd(env *Env, opts commentAddOptions, 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.") 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.") diff --git a/commands/title_edit.go b/commands/title_edit.go index 455c9384..09415e49 100644 --- a/commands/title_edit.go +++ b/commands/title_edit.go @@ -9,7 +9,8 @@ import ( ) type titleEditOptions struct { - title string + title string + nonInteractive bool } func newTitleEditCommand() *cobra.Command { @@ -32,6 +33,7 @@ func newTitleEditCommand() *cobra.Command { flags.StringVarP(&options.title, "title", "t", "", "Provide a title to describe the issue", ) + flags.BoolVar(&options.nonInteractive, "non-interactive", false, "Do not ask for user input") return cmd } @@ -45,6 +47,10 @@ func runTitleEdit(env *Env, opts titleEditOptions, args []string) error { snap := b.Snapshot() if opts.title == "" { + if opts.nonInteractive { + env.err.Println("No title given. Use -m or -F option to specify a title. Aborting.") + return nil + } opts.title, err = input.BugTitleEditorInput(env.repo, snap.Title) if err == input.ErrEmptyTitle { env.out.Println("Empty title, aborting.") diff --git a/commands/user_create.go b/commands/user_create.go index 06879f2e..0dcfa9b3 100644 --- a/commands/user_create.go +++ b/commands/user_create.go @@ -7,9 +7,10 @@ import ( ) type createUserOptions struct { - name string - email string - avatarURL string + name string + email string + avatarURL string + nonInteractive bool } func newUserCreateCommand() *cobra.Command { @@ -30,13 +31,14 @@ func newUserCreateCommand() *cobra.Command { flags.StringVarP(&options.name, "name", "n", "", "Name to identify the user") flags.StringVarP(&options.email, "email", "e", "", "Email of the user") flags.StringVarP(&options.avatarURL, "avatar", "a", "", "Avatar URL") + flags.BoolVar(&options.nonInteractive, "non-interactive", false, "Do not ask for user input") return cmd } func runUserCreate(env *Env, opts createUserOptions) error { - if opts.name == "" { + if !opts.nonInteractive && opts.name == "" { preName, err := env.backend.GetUserName() if err != nil { return err @@ -47,7 +49,7 @@ func runUserCreate(env *Env, opts createUserOptions) error { } } - if opts.email == "" { + if !opts.nonInteractive && opts.email == "" { preEmail, err := env.backend.GetUserEmail() if err != nil { return err @@ -59,7 +61,7 @@ func runUserCreate(env *Env, opts createUserOptions) error { } } - if opts.avatarURL == "" { + if !opts.nonInteractive && opts.avatarURL == "" { var err error opts.avatarURL, err = input.Prompt("Avatar URL", "avatar") if err != nil { |