Skip to content

Commit

Permalink
Optionally pass labels JSON via command line, fixes kylemacey#1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrngm committed Oct 27, 2018
1 parent 076b82b commit e443aee
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
Expand All @@ -14,8 +15,13 @@ import (
)

func main() {
if len(os.Args) != 2 {
fmt.Printf("Usage: %s <user/repository>\n\n", os.Args[0])
jsonFile := flag.String("json", "example.json", "Use this JSON file for user labels")
flag.Parse()

if len(flag.Args()) != 1 {
fmt.Printf("Usage: %s [-json file] <user/repository>\n\n", os.Args[0])
flag.PrintDefaults()
fmt.Println()
fmt.Println("Don't forget to set the environment variable OCTOKIT_ACCESS_TOKEN.")
return
}
Expand All @@ -28,7 +34,7 @@ func main() {

userlabels := make([]UserLabel, 0)

json.Unmarshal(getJsonFromFile("example.json"), &userlabels)
json.Unmarshal(getJsonFromFile(*jsonFile), &userlabels)

for i := 0; i < len(userlabels); i++ {
if contains(labels, userlabels[i].Name) {
Expand Down

0 comments on commit e443aee

Please sign in to comment.