select first argument on startup

Related #101
This commit is contained in:
Gokcehan committed 2019-02-10 19:48:49 +03:00
1 parent 35930924a7
commit 27f104b3e6
2 files changed
+10 -7

No files matched your search

+6
View File
@@ -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)
+4 -7
View File
@@ -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)
}