go-jira / jira

simple jira command line client in Go
Apache License 2.0
2.68k stars 328 forks source link

Defining your own sub-commands? #15

Closed oschrenk closed 9 years ago

oschrenk commented 9 years ago

New to go and this templating thing. Is it possible to define your own subcommands?

I would love to have jira sprint to run jira ls --query="sprint in openSprints() and project=ACME"

I tried to go with something like

case $JIRA_OPERATION in
  sprint)
    echo "wohoo"
    ;;
  list)
    echo "template: table"
    ;;
esac

but that fails.

coryb commented 9 years ago

Yup, you can do that, it shoud look something like this:

case $JIRA_OPERATION in
  sprint)
    echo "command: list"
    echo "query: sprint in openSprints() and project=ACME"
    echo "template: table"
    ;;
  list)
   echo "template: table"
   ;;
esac

You needed to set the "command" property to that the internal go-jira command would be.

I have also use an ego command so show me everything open and assigned to me:

case $JIRA_OPERATION in
  mine)
    echo "command: list"
    echo "query: status not in ('CLOSED', 'RESOLVED') and assignee=$USER ORDER BY priority asc, created"
    echo "template: table"
    ;;;
esac
oschrenk commented 9 years ago

Awesome! Exactly what I needed!