change directory to the first argument on startup

Mentioned in #63.
This commit is contained in:
Gokcehan committed 2017-10-30 23:08:39 +03:00
1 parent 9092dc6369
commit 94bb62f7c0
1 file changed
+13
+13
View File
@@ -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