From eb39c5c29bc0e9b5e15a940a1b71bdac688b6535 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 31 Jul 2018 15:18:09 +0200 Subject: cli: rework new and comment command to better use the editor a nice templace is now provided with explanations new: title and message can now be provided from the editor. Title will be the first non-empty line --- commands/comment.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'commands/comment.go') diff --git a/commands/comment.go b/commands/comment.go index ebbeaa77..cebf729c 100644 --- a/commands/comment.go +++ b/commands/comment.go @@ -2,9 +2,10 @@ package commands import ( "errors" + "fmt" "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/bug/operations" - "github.com/MichaelMure/git-bug/commands/input" + "github.com/MichaelMure/git-bug/input" "github.com/spf13/cobra" ) @@ -32,8 +33,13 @@ func runComment(cmd *cobra.Command, args []string) error { return err } } - if commentMessageFile == "" && commentMessage == "" { - commentMessage, err = input.LaunchEditor(repo, messageFilename) + + if commentMessage == "" { + commentMessage, err = input.BugCommentEditorInput(repo, messageFilename) + if err == input.ErrEmptyMessage { + fmt.Println("Empty message, aborting.") + return nil + } if err != nil { return err } -- cgit