mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 20:53:27 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 172793ea69 | |||
| dc504de271 | |||
| 986cc78ed5 | |||
| 3913726991 | |||
| 0ba8aa035b | |||
| 098eb99ed6 | |||
| 2ddaed2c29 | |||
| 9a62d1a553 | |||
| 74d7287589 | |||
| c6e4b3dc0e | |||
| 8b5e7b7568 |
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.11 - 2017-09-26
|
||||
|
||||
* [[#115](https://github.com/Netflix-Skunkworks/go-jira/issues/115)] fix transition template for description [Cory Bennett] [[986cc78](https://github.com/Netflix-Skunkworks/go-jira/commit/986cc78)]
|
||||
* update edit command to set queryFields on search to match what is used in template [Cory Bennett] [[3913726](https://github.com/Netflix-Skunkworks/go-jira/commit/3913726)]
|
||||
* fix edit with query loop, allow continuation when not submitting previous issue [Cory Bennett] [[0ba8aa0](https://github.com/Netflix-Skunkworks/go-jira/commit/0ba8aa0)]
|
||||
* fix edit when priority is not set [Cory Bennett] [[098eb99](https://github.com/Netflix-Skunkworks/go-jira/commit/098eb99)]
|
||||
* flatten CommandRegistry list to make it more readable [Cory Bennett] [[2ddaed2](https://github.com/Netflix-Skunkworks/go-jira/commit/2ddaed2)]
|
||||
|
||||
## 1.0.10 - 2017-09-18
|
||||
|
||||
* clean up usage formatting, print aliases [Cory Bennett] [[9f433ac](https://github.com/Netflix-Skunkworks/go-jira/commit/9f433ac)]
|
||||
|
||||
@@ -41,7 +41,7 @@ all:
|
||||
go get -u github.com/karalabe/xgo
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
xgo --targets="freebsd/amd64,linux/386,linux/amd64,windows/386,windows/amd64,darwin/amd64" -dest ./dist -ldflags="-w -s" ./cmd/jira
|
||||
xgo --go 1.9.0 --targets="freebsd/amd64,linux/386,linux/amd64,windows/386,windows/amd64,darwin/amd64" -dest ./dist -ldflags="-w -s" ./cmd/jira
|
||||
|
||||
install:
|
||||
${MAKE} GOBIN=$$HOME/bin build
|
||||
@@ -68,7 +68,7 @@ update-changelog:
|
||||
release:
|
||||
perl -pi -e 'undef $$/; s/\n```\nusage.*```//sg' README.md
|
||||
echo '```' >> README.md
|
||||
./jira --help >> README.md || true
|
||||
./jira --help >> README.md 2>&1 || true
|
||||
echo '```' >> README.md
|
||||
git diff --exit-code --quiet README.md || git commit -m "Updated Usage" README.md
|
||||
git commit -m "Updated Changelog" CHANGELOG.md
|
||||
|
||||
@@ -3,6 +3,34 @@
|
||||
[](https://godoc.org/gopkg.in/Netflix-Skunkworks/go-jira.v1)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
|
||||
### Table of Contents
|
||||
|
||||
* [Summary](#go-jira)
|
||||
* [Install](#install)
|
||||
* [Download](#download)
|
||||
* [Build](#build)
|
||||
* [v1 vs v0 changes](#v1-vs-v0-changes)
|
||||
* [<strong>Golang library import</strong>](#golang-library-import)
|
||||
* [<strong>Configs per command</strong>](#configs-per-command)
|
||||
* [<strong>Custom Commands</strong>](#custom-commands)
|
||||
* [<strong>Incompatible command changes</strong>](#incompatible-command-changes)
|
||||
* [<strong>Login process change</strong>](#login-process-change)
|
||||
* [Configuration](#configuration)
|
||||
* [Dynamic Configuration](#dynamic-configuration)
|
||||
* [Custom Commands](#custom-commands-1)
|
||||
* [Commands](#commands)
|
||||
* [Options](#options)
|
||||
* [Arguments](#arguments)
|
||||
* [Script Template](#script-template)
|
||||
* [Examples](#examples)
|
||||
* [Editing](#editing)
|
||||
* [Templates](#templates)
|
||||
* [Writing/Editing Templates](#writingediting-templates)
|
||||
* [Authentication](#authentication)
|
||||
* [keyring password source](#keyring-password-source)
|
||||
* [pass password source](#pass-password-source)
|
||||
* [Usage](#usage)
|
||||
|
||||
# go-jira
|
||||
simple command line client for Atlassian's Jira service written in Go
|
||||
|
||||
@@ -395,4 +423,75 @@ export GPG_TTY=$(tty)
|
||||
## Usage
|
||||
|
||||
```
|
||||
usage: jira [<flags>] <command> [<args> ...]
|
||||
|
||||
Jira Command Line Interface
|
||||
|
||||
Global flags:
|
||||
--help Show context-sensitive help (also try --help-long and --help-man).
|
||||
-v, --verbose ... Increase verbosity for debugging
|
||||
-e, --endpoint=ENDPOINT Base URI to use for Jira
|
||||
-k, --insecure Disable TLS certificate verification
|
||||
-Q, --quiet Suppress output to console
|
||||
--unixproxy=UNIXPROXY Path for a unix-socket proxy
|
||||
-u, --user=USER Login name used for authentication with Jira service
|
||||
|
||||
Commands:
|
||||
help: Show help.
|
||||
version: Prints version
|
||||
acknowledge: Transition issue to acknowledge state
|
||||
assign: Assign user to issue
|
||||
attach create: Attach file to issue
|
||||
attach get: Fetch attachment
|
||||
attach list: Prints attachment details for issue
|
||||
attach remove: Delete attachment
|
||||
backlog: Transition issue to Backlog state
|
||||
block: Mark issues as blocker
|
||||
browse: Open issue in browser
|
||||
close: Transition issue to close state
|
||||
comment: Add comment to issue
|
||||
component add: Add component
|
||||
components: Show components for a project
|
||||
create: Create issue
|
||||
createmeta: View 'create' metadata
|
||||
done: Transition issue to Done state
|
||||
dup: Mark issues as duplicate
|
||||
edit: Edit issue details
|
||||
editmeta: View 'edit' metadata
|
||||
epic add: Add issues to Epic
|
||||
epic create: Create Epic
|
||||
epic list: Prints list of issues for an epic with optional search criteria
|
||||
epic remove: Remove issues from Epic
|
||||
export-templates: Export templates for customizations
|
||||
fields: Prints all fields, both System and Custom
|
||||
in-progress: Transition issue to Progress state
|
||||
issuelink: Link two issues
|
||||
issuelinktypes: Show the issue link types
|
||||
issuetypes: Show issue types for a project
|
||||
labels add: Add labels to an issue
|
||||
labels remove: Remove labels from an issue
|
||||
labels set: Set labels on an issue
|
||||
list: Prints list of issues for given search criteria
|
||||
login: Attempt to login into jira server
|
||||
logout: Deactivate sesssion with Jira server
|
||||
rank: Mark issues as blocker
|
||||
reopen: Transition issue to reopen state
|
||||
request: Open issue in requestr
|
||||
resolve: Transition issue to resolve state
|
||||
start: Transition issue to start state
|
||||
stop: Transition issue to stop state
|
||||
subtask: Subtask issue
|
||||
take: Assign issue to yourself
|
||||
todo: Transition issue to To Do state
|
||||
transition: Transition issue to given state
|
||||
transitions: List valid issue transitions
|
||||
transmeta: List valid issue transitions
|
||||
unassign: Unassign an issue
|
||||
unexport-templates: Remove unmodified exported templates
|
||||
view: Prints issue details
|
||||
vote: Vote up/down an issue
|
||||
watch: Add/Remove watcher to issue
|
||||
worklog add: Add a worklog to an issue
|
||||
worklog list: Prints the worklog data for given issue
|
||||
|
||||
```
|
||||
|
||||
+54
-229
@@ -189,235 +189,60 @@ func main() {
|
||||
o := oreo.New().WithCookieFile(filepath.Join(jiracli.Homedir(), fig.ConfigDir, "cookies.js"))
|
||||
|
||||
registry := []jiracli.CommandRegistry{
|
||||
jiracli.CommandRegistry{
|
||||
Command: "acknowledge",
|
||||
Aliases: []string{"ack"},
|
||||
Entry: jiracmd.CmdTransitionRegistry("acknowledge"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "assign",
|
||||
Entry: jiracmd.CmdAssignRegistry(),
|
||||
Aliases: []string{"give"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "attach create",
|
||||
Entry: jiracmd.CmdAttachCreateRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "attach get",
|
||||
Entry: jiracmd.CmdAttachGetRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "attach list",
|
||||
Entry: jiracmd.CmdAttachListRegistry(),
|
||||
Aliases: []string{"ls"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "attach remove",
|
||||
Entry: jiracmd.CmdAttachRemoveRegistry(),
|
||||
Aliases: []string{"rm"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "backlog",
|
||||
Entry: jiracmd.CmdTransitionRegistry("Backlog"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "block",
|
||||
Entry: jiracmd.CmdBlockRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "browse",
|
||||
Entry: jiracmd.CmdBrowseRegistry(),
|
||||
Aliases: []string{"b"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "close",
|
||||
Entry: jiracmd.CmdTransitionRegistry("close"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "comment",
|
||||
Entry: jiracmd.CmdCommentRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "component add",
|
||||
Entry: jiracmd.CmdComponentAddRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "components",
|
||||
Entry: jiracmd.CmdComponentsRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "create",
|
||||
Entry: jiracmd.CmdCreateRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "createmeta",
|
||||
Entry: jiracmd.CmdCreateMetaRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "done",
|
||||
Entry: jiracmd.CmdTransitionRegistry("Done"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "dup",
|
||||
Entry: jiracmd.CmdDupRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "edit",
|
||||
Entry: jiracmd.CmdEditRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "editmeta",
|
||||
Entry: jiracmd.CmdEditMetaRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "epic add",
|
||||
Entry: jiracmd.CmdEpicAddRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "epic create",
|
||||
Entry: jiracmd.CmdEpicCreateRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "epic list",
|
||||
Entry: jiracmd.CmdEpicListRegistry(),
|
||||
Aliases: []string{"ls"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "epic remove",
|
||||
Entry: jiracmd.CmdEpicRemoveRegistry(),
|
||||
Aliases: []string{"rm"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "export-templates",
|
||||
Entry: jiracmd.CmdExportTemplatesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "fields",
|
||||
Entry: jiracmd.CmdFieldsRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "in-progress",
|
||||
Aliases: []string{"prog", "progress"},
|
||||
Entry: jiracmd.CmdTransitionRegistry("Progress"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuelink",
|
||||
Entry: jiracmd.CmdIssueLinkRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuelinktypes",
|
||||
Entry: jiracmd.CmdIssueLinkTypesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "issuetypes",
|
||||
Entry: jiracmd.CmdIssueTypesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels add",
|
||||
Entry: jiracmd.CmdLabelsAddRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels remove",
|
||||
Entry: jiracmd.CmdLabelsRemoveRegistry(),
|
||||
Aliases: []string{"rm"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "labels set",
|
||||
Entry: jiracmd.CmdLabelsSetRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Entry: jiracmd.CmdListRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "login",
|
||||
Entry: jiracmd.CmdLoginRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "logout",
|
||||
Entry: jiracmd.CmdLogoutRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "rank",
|
||||
Entry: jiracmd.CmdRankRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "reopen",
|
||||
Entry: jiracmd.CmdTransitionRegistry("reopen"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "request",
|
||||
Entry: jiracmd.CmdRequestRegistry(),
|
||||
Aliases: []string{"req"},
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "resolve",
|
||||
Entry: jiracmd.CmdTransitionRegistry("resolve"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "start",
|
||||
Entry: jiracmd.CmdTransitionRegistry("start"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "stop",
|
||||
Entry: jiracmd.CmdTransitionRegistry("stop"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "subtask",
|
||||
Entry: jiracmd.CmdSubtaskRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "take",
|
||||
Entry: jiracmd.CmdTakeRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "todo",
|
||||
Entry: jiracmd.CmdTransitionRegistry("To Do"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transition",
|
||||
Aliases: []string{"trans"},
|
||||
Entry: jiracmd.CmdTransitionRegistry(""),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transitions",
|
||||
Entry: jiracmd.CmdTransitionsRegistry("transitions"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "transmeta",
|
||||
Entry: jiracmd.CmdTransitionsRegistry("debug"),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "unassign",
|
||||
Entry: jiracmd.CmdUnassignRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "unexport-templates",
|
||||
Entry: jiracmd.CmdUnexportTemplatesRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "view",
|
||||
Entry: jiracmd.CmdViewRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "vote",
|
||||
Entry: jiracmd.CmdVoteRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "watch",
|
||||
Entry: jiracmd.CmdWatchRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "worklog add",
|
||||
Entry: jiracmd.CmdWorklogAddRegistry(),
|
||||
},
|
||||
jiracli.CommandRegistry{
|
||||
Command: "worklog list",
|
||||
Entry: jiracmd.CmdWorklogListRegistry(),
|
||||
Default: true,
|
||||
},
|
||||
{Command: "acknowledge", Entry: jiracmd.CmdTransitionRegistry("acknowledge"), Aliases: []string{"ack"}},
|
||||
{Command: "assign", Entry: jiracmd.CmdAssignRegistry(), Aliases: []string{"give"}},
|
||||
{Command: "attach create", Entry: jiracmd.CmdAttachCreateRegistry()},
|
||||
{Command: "attach get", Entry: jiracmd.CmdAttachGetRegistry()},
|
||||
{Command: "attach list", Entry: jiracmd.CmdAttachListRegistry(), Aliases: []string{"ls"}},
|
||||
{Command: "attach remove", Entry: jiracmd.CmdAttachRemoveRegistry(), Aliases: []string{"rm"}},
|
||||
{Command: "backlog", Entry: jiracmd.CmdTransitionRegistry("Backlog")},
|
||||
{Command: "block", Entry: jiracmd.CmdBlockRegistry()},
|
||||
{Command: "browse", Entry: jiracmd.CmdBrowseRegistry(), Aliases: []string{"b"}},
|
||||
{Command: "close", Entry: jiracmd.CmdTransitionRegistry("close")},
|
||||
{Command: "comment", Entry: jiracmd.CmdCommentRegistry()},
|
||||
{Command: "component add", Entry: jiracmd.CmdComponentAddRegistry()},
|
||||
{Command: "components", Entry: jiracmd.CmdComponentsRegistry()},
|
||||
{Command: "create", Entry: jiracmd.CmdCreateRegistry()},
|
||||
{Command: "createmeta", Entry: jiracmd.CmdCreateMetaRegistry()},
|
||||
{Command: "done", Entry: jiracmd.CmdTransitionRegistry("Done")},
|
||||
{Command: "dup", Entry: jiracmd.CmdDupRegistry()},
|
||||
{Command: "edit", Entry: jiracmd.CmdEditRegistry()},
|
||||
{Command: "editmeta", Entry: jiracmd.CmdEditMetaRegistry()},
|
||||
{Command: "epic add", Entry: jiracmd.CmdEpicAddRegistry()},
|
||||
{Command: "epic create", Entry: jiracmd.CmdEpicCreateRegistry()},
|
||||
{Command: "epic list", Entry: jiracmd.CmdEpicListRegistry(), Aliases: []string{"ls"}},
|
||||
{Command: "epic remove", Entry: jiracmd.CmdEpicRemoveRegistry(), Aliases: []string{"rm"}},
|
||||
{Command: "export-templates", Entry: jiracmd.CmdExportTemplatesRegistry()},
|
||||
{Command: "fields", Entry: jiracmd.CmdFieldsRegistry()},
|
||||
{Command: "in-progress", Entry: jiracmd.CmdTransitionRegistry("Progress"), Aliases: []string{"prog", "progress"}},
|
||||
{Command: "issuelink", Entry: jiracmd.CmdIssueLinkRegistry()},
|
||||
{Command: "issuelinktypes", Entry: jiracmd.CmdIssueLinkTypesRegistry()},
|
||||
{Command: "issuetypes", Entry: jiracmd.CmdIssueTypesRegistry()},
|
||||
{Command: "labels add", Entry: jiracmd.CmdLabelsAddRegistry()},
|
||||
{Command: "labels remove", Entry: jiracmd.CmdLabelsRemoveRegistry(), Aliases: []string{"rm"}},
|
||||
{Command: "labels set", Entry: jiracmd.CmdLabelsSetRegistry()},
|
||||
{Command: "list", Entry: jiracmd.CmdListRegistry(), Aliases: []string{"ls"}},
|
||||
{Command: "login", Entry: jiracmd.CmdLoginRegistry()},
|
||||
{Command: "logout", Entry: jiracmd.CmdLogoutRegistry()},
|
||||
{Command: "rank", Entry: jiracmd.CmdRankRegistry()},
|
||||
{Command: "reopen", Entry: jiracmd.CmdTransitionRegistry("reopen")},
|
||||
{Command: "request", Entry: jiracmd.CmdRequestRegistry(), Aliases: []string{"req"}},
|
||||
{Command: "resolve", Entry: jiracmd.CmdTransitionRegistry("resolve")},
|
||||
{Command: "start", Entry: jiracmd.CmdTransitionRegistry("start")},
|
||||
{Command: "stop", Entry: jiracmd.CmdTransitionRegistry("stop")},
|
||||
{Command: "subtask", Entry: jiracmd.CmdSubtaskRegistry()},
|
||||
{Command: "take", Entry: jiracmd.CmdTakeRegistry()},
|
||||
{Command: "todo", Entry: jiracmd.CmdTransitionRegistry("To Do")},
|
||||
{Command: "transition", Entry: jiracmd.CmdTransitionRegistry(""), Aliases: []string{"trans"}},
|
||||
{Command: "transitions", Entry: jiracmd.CmdTransitionsRegistry("transitions")},
|
||||
{Command: "transmeta", Entry: jiracmd.CmdTransitionsRegistry("debug")},
|
||||
{Command: "unassign", Entry: jiracmd.CmdUnassignRegistry()},
|
||||
{Command: "unexport-templates", Entry: jiracmd.CmdUnexportTemplatesRegistry()},
|
||||
{Command: "view", Entry: jiracmd.CmdViewRegistry()},
|
||||
{Command: "vote", Entry: jiracmd.CmdVoteRegistry()},
|
||||
{Command: "watch", Entry: jiracmd.CmdWatchRegistry()},
|
||||
{Command: "worklog add", Entry: jiracmd.CmdWorklogAddRegistry()},
|
||||
{Command: "worklog list", Entry: jiracmd.CmdWorklogListRegistry(), Default: true},
|
||||
}
|
||||
|
||||
jiracli.Register(app, o, fig, registry)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
var log = logging.MustGetLogger("jira")
|
||||
|
||||
const VERSION = "1.0.10"
|
||||
const VERSION = "1.0.11"
|
||||
|
||||
type Jira struct {
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
|
||||
+16
-14
@@ -250,15 +250,17 @@ func (o *CommonOptions) editFile(fileName string) (changes bool, err error) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var EditLoopAbort = fmt.Errorf("Edit Loop aborted by request")
|
||||
|
||||
func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error {
|
||||
tmpFile, err := tmpTemplate(opts.Template.Value, input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
confirm := func(msg string) (answer bool) {
|
||||
confirm := func(dflt bool, msg string) (answer bool) {
|
||||
survey.AskOne(
|
||||
&survey.Confirm{Message: msg, Default: true},
|
||||
&survey.Confirm{Message: msg, Default: dflt},
|
||||
&answer,
|
||||
nil,
|
||||
)
|
||||
@@ -279,14 +281,14 @@ func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit
|
||||
changes, err := opts.editFile(tmpFile)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
if confirm("Editor reported an error, edit again?") {
|
||||
if confirm(true, "Editor reported an error, edit again?") {
|
||||
continue
|
||||
}
|
||||
panic(Exit{Code: 1})
|
||||
return EditLoopAbort
|
||||
}
|
||||
if !changes {
|
||||
if !confirm("No changes detected, submit anyway?") {
|
||||
panic(Exit{Code: 1})
|
||||
if !confirm(false, "No changes detected, submit anyway?") {
|
||||
return EditLoopAbort
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,35 +321,35 @@ func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit
|
||||
var raw interface{}
|
||||
if err := yaml.Unmarshal(data, &raw); err != nil {
|
||||
log.Error(err.Error())
|
||||
if confirm("Invalid YAML syntax, edit again?") {
|
||||
if confirm(true, "Invalid YAML syntax, edit again?") {
|
||||
continue
|
||||
}
|
||||
panic(Exit{Code: 1})
|
||||
return EditLoopAbort
|
||||
}
|
||||
yamlFixup(&raw)
|
||||
fixedYAML, err := yaml.Marshal(&raw)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
if confirm("Invalid YAML syntax, edit again?") {
|
||||
if confirm(true, "Invalid YAML syntax, edit again?") {
|
||||
continue
|
||||
}
|
||||
panic(Exit{Code: 1})
|
||||
return EditLoopAbort
|
||||
}
|
||||
|
||||
if err := yaml.Unmarshal(fixedYAML, output); err != nil {
|
||||
log.Error(err.Error())
|
||||
if confirm("Invalid YAML syntax, edit again?") {
|
||||
if confirm(true, "Invalid YAML syntax, edit again?") {
|
||||
continue
|
||||
}
|
||||
panic(Exit{Code: 1})
|
||||
return EditLoopAbort
|
||||
}
|
||||
// submit template
|
||||
if err := submit(); err != nil {
|
||||
log.Error(err.Error())
|
||||
if confirm("Jira reported an error, edit again?") {
|
||||
if confirm(true, "Jira reported an error, edit again?") {
|
||||
continue
|
||||
}
|
||||
panic(Exit{Code: 1})
|
||||
return EditLoopAbort
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ comments:
|
||||
{{end -}}
|
||||
`
|
||||
const defaultEditTemplate = `{{/* edit template */ -}}
|
||||
# issue: {{ .key }}
|
||||
# issue: {{ .key }} - created: {{ .fields.created | age}} ago
|
||||
update:
|
||||
comment:
|
||||
- add:
|
||||
@@ -352,9 +352,10 @@ fields:
|
||||
- name: {{ .overrides.watcher}}{{end}}{{end}}
|
||||
{{- if .meta.fields.priority }}
|
||||
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
|
||||
name: {{ or .overrides.priority .fields.priority.name }}{{end}}
|
||||
name: {{ or .overrides.priority .fields.priority.name "" }}{{end}}
|
||||
description: |~
|
||||
{{ or .overrides.description (or .fields.description "") | indent 4 }}
|
||||
{{ or .overrides.description .fields.description "" | indent 4 }}
|
||||
# votes: {{ .fields.votes.votes }}
|
||||
# comments:
|
||||
# {{ range .fields.comment.comments }} - | # {{.author.name}}, {{.created | age}} ago
|
||||
# {{ or .body "" | indent 4 | comment}}
|
||||
@@ -473,7 +474,8 @@ fields:
|
||||
- name: {{ .name }}{{end}}{{end}}
|
||||
{{- end -}}
|
||||
{{if .meta.fields.description}}
|
||||
description: {{or .overrides.description .fields.description }}
|
||||
description: |~
|
||||
{{ or .fields.description "" | indent 4 }}
|
||||
{{- end -}}
|
||||
{{if .meta.fields.fixVersions -}}
|
||||
{{if .meta.fields.fixVersions.allowedValues}}
|
||||
|
||||
+22
-2
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
|
||||
"gopkg.in/AlecAivazis/survey.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
|
||||
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
||||
@@ -33,6 +33,9 @@ func CmdEditRegistry() *jiracli.CommandRegistryEntry {
|
||||
"Edit issue details",
|
||||
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
||||
jiracli.LoadConfigs(cmd, fig, &opts)
|
||||
if opts.QueryFields == "" {
|
||||
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated,issuetype,comments,description,votes,created,customfield_10110,components"
|
||||
}
|
||||
return CmdEditUsage(cmd, &opts, fig)
|
||||
},
|
||||
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
|
||||
@@ -106,7 +109,7 @@ func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, issueData := range results.Issues {
|
||||
for i, issueData := range results.Issues {
|
||||
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, issueData.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -121,6 +124,23 @@ func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions)
|
||||
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
|
||||
return jira.EditIssue(o, globals.Endpoint.Value, issueData.Key, &issueUpdate)
|
||||
})
|
||||
if err == jiracli.EditLoopAbort {
|
||||
if len(results.Issues) > i+1 {
|
||||
var answer bool
|
||||
survey.AskOne(
|
||||
&survey.Confirm{
|
||||
Message: fmt.Sprintf("Continue to edit next issue %s?", results.Issues[i+1].Key),
|
||||
Default: true,
|
||||
},
|
||||
&answer,
|
||||
nil,
|
||||
)
|
||||
if answer {
|
||||
continue
|
||||
}
|
||||
panic(jiracli.Exit{1})
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user