-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
take
, unassign
and assign|give
commands
- Loading branch information
Showing
7 changed files
with
157 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package jiracli | ||
|
||
import ( | ||
"fmt" | ||
|
||
kingpin "gopkg.in/alecthomas/kingpin.v2" | ||
) | ||
|
||
type AssignOptions struct { | ||
GlobalOptions | ||
Issue string | ||
Assignee string | ||
} | ||
|
||
func (jc *JiraCli) CmdAssignRegistry() *CommandRegistryEntry { | ||
opts := AssignOptions{} | ||
|
||
return &CommandRegistryEntry{ | ||
"Assign user to issue", | ||
func() error { | ||
return jc.CmdAssign(&opts) | ||
}, | ||
func(cmd *kingpin.CmdClause) error { | ||
return jc.CmdAssignUsage(cmd, &opts) | ||
}, | ||
} | ||
} | ||
|
||
func (jc *JiraCli) CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error { | ||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil { | ||
return err | ||
} | ||
cmd.Flag("default", "use default user for assignee").PreAction(func(ctx *kingpin.ParseContext) error { | ||
if flagValue(ctx, "default") == "true" { | ||
opts.Assignee = "-1" | ||
} | ||
return nil | ||
}).Bool() | ||
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue) | ||
cmd.Arg("ASSIGNEE", "user to assign to issue").StringVar(&opts.Assignee) | ||
return nil | ||
} | ||
|
||
// CmdAssign will assign an issue to a user | ||
func (jc *JiraCli) CmdAssign(opts *AssignOptions) error { | ||
err := jc.IssueAssign(opts.Issue, opts.Assignee) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, jc.Endpoint, opts.Issue) | ||
|
||
// FIXME implement browse | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package jiracli | ||
|
||
import kingpin "gopkg.in/alecthomas/kingpin.v2" | ||
|
||
func (jc *JiraCli) CmdTakeRegistry() *CommandRegistryEntry { | ||
opts := AssignOptions{} | ||
|
||
return &CommandRegistryEntry{ | ||
"Assign issue to yourself", | ||
func() error { | ||
opts.Assignee = opts.User | ||
return jc.CmdAssign(&opts) | ||
}, | ||
func(cmd *kingpin.CmdClause) error { | ||
return jc.CmdAssignUsage(cmd, &opts) | ||
}, | ||
} | ||
} | ||
|
||
func (jc *JiraCli) CmdTakeUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error { | ||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil { | ||
return err | ||
} | ||
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jiracli | ||
|
||
import kingpin "gopkg.in/alecthomas/kingpin.v2" | ||
|
||
func (jc *JiraCli) CmdUnassignRegistry() *CommandRegistryEntry { | ||
opts := AssignOptions{} | ||
|
||
return &CommandRegistryEntry{ | ||
"Unassign an issue", | ||
func() error { | ||
return jc.CmdAssign(&opts) | ||
}, | ||
func(cmd *kingpin.CmdClause) error { | ||
return jc.CmdAssignUsage(cmd, &opts) | ||
}, | ||
} | ||
} | ||
|
||
func (jc *JiraCli) CmdUnassignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error { | ||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil { | ||
return err | ||
} | ||
cmd.Arg("ISSUE", "issue to unassign").Required().StringVar(&opts.Issue) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters