aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-13 16:13:40 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-13 16:13:40 +0200
commitbc12fee58e8bd86672793ae37d9f924158afb482 (patch)
treeb6506af647a5e6d3d8c053f2b284a3adc335d35b /commands
parente02294c8f372156945bbc43d70d4d36a07a3fbcf (diff)
downloadgit-bug-bc12fee58e8bd86672793ae37d9f924158afb482.tar.gz
create the Bug structure
Diffstat (limited to 'commands')
-rw-r--r--commands/commands.go12
-rw-r--r--commands/new.go23
2 files changed, 10 insertions, 25 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 64b2cbc1..2cc16380 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -27,16 +27,4 @@ var CommandMap = map[string]*Command{
"new": newCmd,
"pull": pullCmd,
"push": pushCmd,
-
- /*"abandon": abandonCmd,
- "accept": acceptCmd,
- "comment": commentCmd,
- "list": listCmd,
- "pull": pullCmd,
- "push": pushCmd,
- "rebase": rebaseCmd,
- "reject": rejectCmd,
- "request": requestCmd,
- "show": showCmd,
- "submit": submitCmd,*/
}
diff --git a/commands/new.go b/commands/new.go
index 6dd19508..f3127fc6 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -1,12 +1,13 @@
package commands
import (
+ "errors"
"flag"
"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/repository"
- "github.com/pkg/errors"
)
var newFlagSet = flag.NewFlagSet("new", flag.ExitOnError)
@@ -16,7 +17,7 @@ var (
newMessage = newFlagSet.String("m", "", "Provide a message to describe the issue")
)
-func newBug(repo repository.Repo, args []string) error {
+func RunNewBug(repo repository.Repo, args []string) error {
newFlagSet.Parse(args)
args = newFlagSet.Args()
@@ -50,19 +51,15 @@ func newBug(repo repository.Repo, args []string) error {
return err
}
- comment := bug.Comment{
- Author: author,
- Message: *newMessage,
- }
-
- bug := bug.Snapshot{
- Title: title,
- Comments: []bug.Comment{comment},
+ newbug, err := bug.NewBug()
+ if err != nil {
+ return err
}
- fmt.Println(bug)
+ createOp := operations.NewCreateOp(author, title, *newMessage)
- author.Store(repo)
+ newbug.Append(createOp)
+ newbug.Commit()
return nil
@@ -73,5 +70,5 @@ var newCmd = &Command{
fmt.Printf("Usage: %s new <title> [<option>...]\n\nOptions:\n", arg0)
newFlagSet.PrintDefaults()
},
- RunMethod: newBug,
+ RunMethod: RunNewBug,
}