diff options
| author | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-11-16 00:53:49 +0300 |
|---|---|---|
| committer | Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> | 2018-11-16 00:53:49 +0300 |
| commit | 8578e308410664e48eb3216e240c891ca3e6d5a2 (patch) | |
| tree | 577c38b0e31d04332572ef7aa3ef14cd82fd76a5 /main.go | |
| parent | pass directory as input arg. (diff) | |
| download | gitbatch-8578e308410664e48eb3216e240c891ca3e6d5a2.tar.gz | |
added command line parser.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 25 |
1 files changed, 8 insertions, 17 deletions
@@ -6,27 +6,18 @@ import ( "os" "os/exec" "syscall" -// "gopkg.in/alecthomas/kingpin.v2" + "gopkg.in/alecthomas/kingpin.v2" ) -//var ( -// currentDirectory, err = os.Getwd() -// directory = kingpin.Flag("directory", "Directory to roam for git repositories.").Default(currentDirectory).Short('d').String() -//) +var ( + currentDir, err = os.Getwd() + dir = kingpin.Flag("directory", "Directory to roam for git repositories.").Default(currentDir).Short('d').String() +) func main() { - - args := os.Args[1:] - if len(args) > 0 { - repo := args[0] - FindRepos(repo) - } else { - repo, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - FindRepos(repo) - } + kingpin.Parse() + log.Printf("the diretory under investigation is %s", *dir) + FindRepos(*dir) } func FindRepos(directory string) []string { |
