-
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
rank ISSUE after|before ISSUE
command
- Loading branch information
Showing
8 changed files
with
107 additions
and
82 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
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,65 @@ | ||
package jiracli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata" | ||
kingpin "gopkg.in/alecthomas/kingpin.v2" | ||
) | ||
|
||
type RankOptions struct { | ||
GlobalOptions | ||
First string | ||
Second string | ||
Order string | ||
} | ||
|
||
func (jc *JiraCli) CmdRankRegistry() *CommandRegistryEntry { | ||
opts := RankOptions{ | ||
GlobalOptions: GlobalOptions{}, | ||
} | ||
|
||
return &CommandRegistryEntry{ | ||
"Mark issues as blocker", | ||
func() error { | ||
return jc.CmdRank(&opts) | ||
}, | ||
func(cmd *kingpin.CmdClause) error { | ||
return jc.CmdRankUsage(cmd, &opts) | ||
}, | ||
} | ||
} | ||
|
||
func (jc *JiraCli) CmdRankUsage(cmd *kingpin.CmdClause, opts *RankOptions) error { | ||
if err := jc.GlobalUsage(cmd, &opts.GlobalOptions); err != nil { | ||
return err | ||
} | ||
cmd.Arg("FIRST-ISSUE", "first issue").Required().StringVar(&opts.First) | ||
cmd.Arg("after|before", "rank ordering").Required().HintOptions("after", "before").EnumVar(&opts.Order, "after", "before") | ||
cmd.Arg("SECOND-ISSUE", "second issue").Required().StringVar(&opts.Second) | ||
return nil | ||
} | ||
|
||
// CmdRank order two issue | ||
func (jc *JiraCli) CmdRank(opts *RankOptions) error { | ||
req := &jiradata.RankRequest{ | ||
Issues: []string{opts.First}, | ||
} | ||
|
||
if opts.Order == "after" { | ||
req.RankAfterIssue = opts.Second | ||
} else { | ||
req.RankBeforeIssue = opts.Second | ||
} | ||
|
||
if err := jc.RankIssues(req); err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("OK %s %s/browse/%s\n", opts.First, jc.Endpoint, opts.First) | ||
fmt.Printf("OK %s %s/browse/%s\n", opts.Second, jc.Endpoint, opts.Second) | ||
|
||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package jiradata | ||
|
||
type RankRequest struct { | ||
Issues []string `json:"issues,omitempty" yaml:"issues,omitempty"` | ||
RankBeforeIssue string `json:"rankBeforeIssue,omitempty" yaml:"rankBeforeIssue,omitempty"` | ||
RankAfterIssue string `json:"rankAfterIssue,omitempty" yaml:"rankAfterIssue,omitempty"` | ||
} |
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