Skip to content

Commit

Permalink
Added some more examples to README + version to jitic
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed Aug 10, 2015
1 parent 5aaea2f commit 37dd6b3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@

## Usage

TODO
```
Usage of ./jitic:
-pass="": JIRA Password.
-stdin=false: Set to true if you want to get "-tickets" from stdin instead of an argument.
-tickets="": Message to retrieve the tickets from.
-url="": JIRA instance URL.
-user="": JIRA Username.
-version=false: Outputs the version number and exits.
```

### Examples

Check if ticket *WEB-22861* exists in *https://jira.example.org/* from parameter.

```bash
./jitic -url="https://jira.example.org/" -user="JIRA-API" -pass="SECRET-PASSWORD" -tickets="This is my commit message for this awesome feature: WEB-22861 remove authentication prod build for now"
```

Check if ticket *WEB-22861* exists in *https://jira.example.org/* from stdin.

```bash
echo "This is my commit message for this awesome feature: WEB-22861 remove authentication prod build for now" | ./jitic -url="https://jira.example.org/" -user="JIRA-API" -pass="SECRET-PASSWORD" -stdin
```

## Use cases

Expand Down Expand Up @@ -40,7 +62,7 @@ exit 0

### Git "pre-receive" hook

See [Customizing Git - Git Hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks).
See [Customizing Git - Git Hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) and [A reasonable git pre-receive-hook](https://gist.github.com/caniszczyk/1327469).

How a pre-receive hook can look like:
```sh
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ package main
import (
"bufio"
"flag"
"fmt"
"github.com/andygrunwald/jitic/jira"
"log"
"net/url"
"os"
"regexp"
)

const (
majorVersion = 0
minorVersion = 0
patchVersion = 1
)

func main() {
var (
jiraURL = flag.String("url", "", "JIRA instance URL.")
jiraUsername = flag.String("user", "", "JIRA Username.")
jiraPassword = flag.String("pass", "", "JIRA Password.")
ticketMessage = flag.String("tickets", "", "Message to retrieve the tickets from.")
inputStdin = flag.Bool("stdin", false, "Set to true if you want to get \"-tickets\" from stdin instead of an argument.")
flagVersion = flag.Bool("version", false, "Outputs the version number and exits.")
)
flag.Parse()

// Output the version and exit
if *flagVersion {
fmt.Printf("jitic v%d.%d.%d\n", majorVersion, minorVersion, patchVersion)
return
}

// Collect all ticket keys
var tickets []string
if len(*ticketMessage) > 0 {
Expand Down

0 comments on commit 37dd6b3

Please sign in to comment.