diff --git a/bug/operation.go b/bug/operation.go
index 9e31637a081800fc1f43c73a561c5e9ecd1e7415..74be2fac0dc5e293add270e74a430132afcc1f39 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -17,6 +17,9 @@ type Operation interface {
OpType() OperationType
Time() time.Time
Apply(snapshot Snapshot) Snapshot
+
+ // TODO: data validation (ex: a title is a single line)
+ // Validate() bool
}
type OpBase struct {
diff --git a/commands/comment.go b/commands/comment.go
index ebbeaa77fbc4e6f4668cde0d2742985dcbd62caa..cebf729cf9a4785d4e0c5eb773ae260140bb2811 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
}
diff --git a/commands/new.go b/commands/new.go
index 4168453eaca128a6e87616b24fa4c9851efab700..88e7cd81ff3e01e18f5b869da042674df3401f77 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -1,39 +1,36 @@
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"
)
var (
- newMessageFile string
+ newTitle string
newMessage string
+ newMessageFile string
)
func runNewBug(cmd *cobra.Command, args []string) error {
var err error
- if len(args) == 0 {
- return errors.New("No title provided")
- }
- if len(args) > 1 {
- return errors.New("Only accepting one title is supported")
- }
-
- title := args[0]
-
if newMessageFile != "" && newMessage == "" {
newMessage, err = input.FromFile(newMessageFile)
if err != nil {
return err
}
}
- if newMessageFile == "" && newMessage == "" {
- newMessage, err = input.LaunchEditor(repo, messageFilename)
+
+ if newMessage == "" || newTitle == "" {
+ newTitle, newMessage, err = input.BugCreateEditorInput(repo, messageFilename, newTitle, newMessage)
+
+ if err == input.ErrEmptyTitle {
+ fmt.Println("Empty title, aborting.")
+ return nil
+ }
if err != nil {
return err
}
@@ -44,7 +41,7 @@ func runNewBug(cmd *cobra.Command, args []string) error {
return err
}
- newBug, err := operations.Create(author, title, newMessage)
+ newBug, err := operations.Create(author, newTitle, newMessage)
if err != nil {
return err
}
@@ -61,7 +58,7 @@ func runNewBug(cmd *cobra.Command, args []string) error {
}
var newCmd = &cobra.Command{
- Use: "new
[