From 94bb62f7c06a1e716bf822475b7249885d97f2ff Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Mon, 30 Oct 2017 23:08:39 +0300 Subject: [PATCH] change directory to the first argument on startup Mentioned in #63. --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index b8f4889..5b61254 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,19 @@ func main() { gSocketProt = gDefaultSocketProt gSocketPath = gDefaultSocketPath + switch flag.NArg() { + case 0: + case 1: + dir := flag.Arg(0) + if err := os.Chdir(dir); err != nil { + fmt.Fprintf(os.Stderr, "%s\n", err) + os.Exit(2) + } + default: + fmt.Fprintf(os.Stderr, "only single directory is allowed\n") + os.Exit(2) + } + if *showDoc { fmt.Print(genDocString) return