Skip to content

Commit 701a1c2

Browse files
committed
Make skipfile a positional argument; add usage
1 parent 5c1272f commit 701a1c2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

skipgen.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,34 @@ func getSkipfileContents(board string, branch string, environment string, skips
8888
return buf
8989
}
9090

91+
func usage() {
92+
fmt.Fprintf(os.Stderr, "Usage:\n %s <skipfile.yaml> [--board <boardname>] [--branch <branchname>] [--environment <environmentname]\n", os.Args[0])
93+
os.Exit(1)
94+
}
95+
9196
func main() {
9297

9398
boardPtr := flag.String("board", "all", "(Optional) board name. If not specified, skips that apply to all boards will be returned.")
9499
branchPtr := flag.String("branch", "all", "(Optional) branch name. If not specified, skips that apply to all branches will be returned.")
95100
environmentPtr := flag.String("environment", "all", "(Optional) environment name. If not specified, skips that apply to all environments will be returned.")
96-
skipfilePtr := flag.String("skipfile", "", "Required. Skipfile in yaml format.")
97101
flag.Parse()
98102

99-
if len(*skipfilePtr) < 1 {
100-
fmt.Fprintf(os.Stderr, "Error: -skipfile not provided\n")
101-
os.Exit(1)
103+
if len(flag.Args()) < 1 {
104+
fmt.Fprintf(os.Stderr, "Error: skipfile not provided\n\n")
105+
usage()
102106
}
103107

104-
_, err := os.Stat(*skipfilePtr)
108+
skipfile := flag.Arg(0)
109+
110+
_, err := os.Stat(skipfile)
105111
if os.IsNotExist(err) {
106-
fmt.Fprintf(os.Stderr, "Error: skipfile '%s' not found\n", *skipfilePtr)
107-
os.Exit(1)
112+
fmt.Fprintf(os.Stderr, "Error: skipfile '%s' not found\n\n", skipfile)
113+
usage()
108114
}
109115
check(err)
110116

111117
// Read skipfile.yaml
112-
buf, err := ioutil.ReadFile(*skipfilePtr)
118+
buf, err := ioutil.ReadFile(skipfile)
113119
check(err)
114120

115121
// Parse skipfile

0 commit comments

Comments
 (0)