-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.go
More file actions
55 lines (39 loc) · 878 Bytes
/
Copy pathcli.go
File metadata and controls
55 lines (39 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"os"
)
const USAGE = `Usage: vim-server [VIM_SERVER_OPTIONS] [OPTIONS] [FILE...]
VIM_SERVER_OPTIONS
-vs-auto, --vs-auto connect automatically if only one server runned
-vs-help, --vs-help show this help message
OPTIONS & FILES
all other flags and arguments are passed directly to the vim
`
type Config struct {
Auto bool
}
func parseFlags() (Config, []string) {
var config Config
var vimFlags []string
args := os.Args[1:]
for i := 0; i < len(args); i++ {
arg := args[i]
if arg == "-vs-auto" || arg == "--vs-auto" {
config.Auto = true
continue
}
if arg == "-vs-help" || arg == "--vs-help" {
fmt.Print(USAGE)
os.Exit(0)
}
vimFlags = append(vimFlags, arg)
}
return config, vimFlags
}
func ask(message string) string {
var input string
fmt.Println(message)
fmt.Scan(&input)
return input
}