Implement attach command
This commit is contained in:
parent
22a1ba56e5
commit
96cadaf4df
4 changed files with 87 additions and 7 deletions
33
cmd/jkl/attach.go
Normal file
33
cmd/jkl/attach.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"otremblay.com/jkl"
|
||||
)
|
||||
|
||||
type AttachCmd struct {
|
||||
args []string
|
||||
file string
|
||||
taskKey string
|
||||
}
|
||||
|
||||
func NewAttachCmd(args []string) (*AttachCmd, error) {
|
||||
ccmd := &AttachCmd{}
|
||||
f := flag.NewFlagSet("x", flag.ExitOnError)
|
||||
f.Parse(args)
|
||||
if len(f.Args()) < 2 {
|
||||
return nil, ErrNotEnoughArgs
|
||||
}
|
||||
ccmd.taskKey = f.Arg(0)
|
||||
ccmd.file = f.Arg(1)
|
||||
return ccmd, nil
|
||||
}
|
||||
|
||||
func (ecmd *AttachCmd) Attach() error {
|
||||
return jkl.Attach(ecmd.taskKey, ecmd.file)
|
||||
}
|
||||
|
||||
func (ecmd *AttachCmd) Run() error {
|
||||
return ecmd.Attach()
|
||||
}
|
||||
|
|
@ -69,6 +69,8 @@ func getCmd(args []string, depth int) (Runner, error) {
|
|||
return NewFlagCmd(args[1:], false)
|
||||
case "link":
|
||||
return NewLinkCmd(args[1:])
|
||||
case "attach":
|
||||
return NewAttachCmd(args[1:])
|
||||
default:
|
||||
// Think about this real hard.
|
||||
// I want `jkl JIRA-1234 done` to move it to done.
|
||||
|
|
@ -100,7 +102,7 @@ func getCmd(args []string, depth int) (Runner, error) {
|
|||
return nil, ErrTaskSubCommandNotFound
|
||||
}
|
||||
|
||||
var verbs = []string{"list", "create", "task", "edit", "comment", "edit-comment"}
|
||||
var verbs = []string{"list", "create", "task", "edit", "comment", "edit-comment", "attach"}
|
||||
|
||||
func init() {
|
||||
sort.Strings(verbs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue