mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-06 04:58:30 +02:00
allow for command aliasing in conjunction with executable config files
This commit is contained in:
+18
-2
@@ -197,7 +197,7 @@ Command Options:
|
|||||||
args := op.Args
|
args := op.Args
|
||||||
opts["overrides"] = overrides
|
opts["overrides"] = overrides
|
||||||
|
|
||||||
command := "view"
|
var command string
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
if alias, ok := jiraCommands[args[0]]; ok {
|
if alias, ok := jiraCommands[args[0]]; ok {
|
||||||
command = alias
|
command = alias
|
||||||
@@ -210,9 +210,22 @@ Command Options:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if command == "" {
|
||||||
|
command = args[0]
|
||||||
|
args = args[1:]
|
||||||
|
}
|
||||||
|
|
||||||
os.Setenv("JIRA_OPERATION", command)
|
os.Setenv("JIRA_OPERATION", command)
|
||||||
loadConfigs(opts)
|
loadConfigs(opts)
|
||||||
|
|
||||||
|
// check to see if it was set in the configs:
|
||||||
|
if value, ok := opts["command"].(string); ok {
|
||||||
|
command = value
|
||||||
|
} else {
|
||||||
|
args = append([]string{command}, args...)
|
||||||
|
command = "view"
|
||||||
|
}
|
||||||
|
|
||||||
// apply defaults
|
// apply defaults
|
||||||
for k, v := range defaults {
|
for k, v := range defaults {
|
||||||
@@ -338,8 +351,11 @@ Command Options:
|
|||||||
err = c.CmdExportTemplates()
|
err = c.CmdExportTemplates()
|
||||||
case "assign":
|
case "assign":
|
||||||
err = c.CmdAssign(args[0], args[1])
|
err = c.CmdAssign(args[0], args[1])
|
||||||
default:
|
case "view":
|
||||||
err = c.CmdView(args[0])
|
err = c.CmdView(args[0])
|
||||||
|
default:
|
||||||
|
log.Error("Unknown command %s", command)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user