aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aports-ghpr.go30
1 files changed, 24 insertions, 6 deletions
diff --git a/aports-ghpr.go b/aports-ghpr.go
index 72bcd87..1d5eaf0 100644
--- a/aports-ghpr.go
+++ b/aports-ghpr.go
@@ -2,6 +2,7 @@ package main
import (
"context"
+ "flag"
"fmt"
"github.com/google/go-github/github"
"log"
@@ -10,10 +11,26 @@ import (
"strings"
)
+var (
+ owner = flag.String("o", "alpinelinux", "GitHub username of the repository owner")
+ repo = flag.String("r", "aports", "Name of the GitHub repository")
+)
+
+func usage() {
+ fmt.Fprintf(flag.CommandLine.Output(), "USAGE: %s [FLAGS] [APORT]\n\n"+
+ "The following flags are supported:\n\n", os.Args[0])
+ flag.PrintDefaults()
+}
+
func main() {
- // TODO: parse options from command line
+ flag.Usage = usage
+ flag.Parse()
+
+ var aport string
+ if flag.NArg() >= 1 {
+ aport = flag.Arg(0)
+ }
- var aport string = ""
// if APKBUILD exists in current directory, then we limit the search
if _, err := os.Stat("APKBUILD"); err == nil {
@@ -25,9 +42,10 @@ func main() {
fmt.Println("searching for: ", aport)
}
- // TODO: allow set this in some config file
- owner := "alpinelinux"
- repo := "aports"
+ if aport == "" {
+ usage()
+ os.Exit(1)
+ }
// TODO: allow set authentication
client := github.NewClient(nil)
@@ -38,7 +56,7 @@ func main() {
ListOptions: github.ListOptions{PerPage: 200},
}
for {
- prs, resp, err := client.PullRequests.List(ctx, owner, repo, opt)
+ prs, resp, err := client.PullRequests.List(ctx, *owner, *repo, opt)
if err != nil {
log.Fatal(err)
}