diff --git a/app.go b/app.go index 14dd75f..68d8ede 100644 --- a/app.go +++ b/app.go @@ -136,6 +136,12 @@ func (app *app) loop() { clientChan := app.ui.readExpr() serverChan := readExpr() + if gSelect != "" { + go func() { + app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1} + }() + } + for _, path := range gConfigPaths { if _, err := os.Stat(path); !os.IsNotExist(err) { app.readFile(path) diff --git a/main.go b/main.go index b922137..2f49c7f 100644 --- a/main.go +++ b/main.go @@ -21,11 +21,12 @@ var ( gHostname string gLastDirPath string gSelectionPath string - gCommand string gSocketProt string gSocketPath string gLogPath string gServerLogPath string + gSelect string + gCommand string gVersion string ) @@ -155,13 +156,9 @@ func main() { os.Exit(2) } case 1: - dir := flag.Arg(0) - if err := os.Chdir(dir); err != nil { - fmt.Fprintf(os.Stderr, "%s\n", err) - os.Exit(2) - } + gSelect = flag.Arg(0) default: - fmt.Fprintf(os.Stderr, "only single directory is allowed\n") + fmt.Fprintf(os.Stderr, "only single file or directory is allowed\n") os.Exit(2) }