[#80] add jira unassign and jira give ISSUE --default commands

This commit is contained in:
Cory Bennett
2017-05-10 08:58:53 -07:00
parent 445f8f1f84
commit 67c86e4858
2 changed files with 28 additions and 4 deletions
+15 -1
View File
@@ -1040,8 +1040,18 @@ func (c *Cli) CmdLabels(action string, issue string, labels []string) error {
func (c *Cli) CmdAssign(issue string, user string) error {
log.Debugf("assign called")
var userVal interface{} = user
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-assign
// If the name is "-1" automatic assignee is used. A null name will remove the assignee.
if user == "" {
userVal = nil
}
if c.GetOptBool("default", false) {
userVal = "-1"
}
json, err := jsonEncode(map[string]interface{}{
"name": user,
"name": userVal,
})
if err != nil {
return err
@@ -1072,6 +1082,10 @@ func (c *Cli) CmdAssign(issue string, user string) error {
return nil
}
func (c *Cli) CmdUnassign(issue string) error {
return c.CmdAssign(issue, "")
}
// CmdExportTemplates will export the default templates to the template directory.
func (c *Cli) CmdExportTemplates() error {
dir := c.opts["directory"].(string)
+13 -3
View File
@@ -82,7 +82,8 @@ Usage:
jira comment ISSUE [--noedit] <Edit Options>
jira (set,add,remove) labels ISSUE [LABEL] ...
jira take ISSUE
jira (assign|give) ISSUE ASSIGNEE
jira (assign|give) ISSUE [ASSIGNEE|--default]
jira unassign ISSUE
jira fields
jira issuelinktypes
jira transmeta ISSUE
@@ -194,6 +195,7 @@ Command Options:
"rank": "rank",
"worklog": "worklog",
"addworklog": "addworklog",
"unassign": "unassign",
}
defaults := map[string]interface{}{
@@ -251,6 +253,7 @@ Command Options:
"Q|quiet": setopt,
"unixproxy": setopt,
"down": setopt,
"default": setopt,
})
if err := op.ProcessAll(os.Args[1:]); err != nil {
@@ -503,8 +506,15 @@ Command Options:
case "export-templates":
err = c.CmdExportTemplates()
case "assign":
requireArgs(2)
err = c.CmdAssign(args[0], args[1])
requireArgs(1)
assignee := ""
if len(args) > 1 {
assignee = args[1]
}
err = c.CmdAssign(args[0], assignee)
case "unassign":
requireArgs(1)
err = c.CmdUnassign(args[0])
case "view":
requireArgs(1)
err = c.CmdView(args[0])