Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 02c2285

Browse files
jrevillasmcuadros
authored andcommitted
Avoid panic if repository is not specified (#79)
1 parent f023635 commit 02c2285

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/basic/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
)
1010

1111
func main() {
12+
if len(os.Args) != 2 {
13+
usage()
14+
os.Exit(1)
15+
}
16+
1217
fmt.Printf("Retrieving %q ...\n", os.Args[1])
1318
r, err := git.NewRepository(os.Args[1], nil)
1419
if err != nil {
@@ -39,3 +44,7 @@ func main() {
3944
fmt.Println(commit)
4045
}
4146
}
47+
48+
func usage() {
49+
fmt.Fprintf(os.Stderr, "%s <repository URL>", os.Args[0])
50+
}

0 commit comments

Comments
 (0)