This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
forked from mdempsky/gocode
-
Notifications
You must be signed in to change notification settings - Fork 28
/
gocode.go
53 lines (47 loc) · 1.45 KB
/
gocode.go
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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
)
var (
g_is_server = flag.Bool("s", false, "run a server instead of a client")
g_format = flag.String("f", "nice", "output format (vim | emacs | nice | csv | json)")
g_input = flag.String("in", "", "use this file instead of stdin input")
g_sock = flag.String("sock", defaultSocketType, "socket type (unix | tcp | none)")
g_addr = flag.String("addr", "127.0.0.1:37373", "address for tcp socket")
g_debug = flag.Bool("debug", false, "enable server-side debug mode")
g_source = flag.Bool("source", false, "use source importer")
g_builtin = flag.Bool("builtin", false, "propose builtin objects")
g_ignore_case = flag.Bool("ignore-case", false, "do case-insensitive matching")
)
func getSocketPath() string {
user := os.Getenv("USER")
if user == "" {
user = "all"
}
return filepath.Join(os.TempDir(), fmt.Sprintf("gocode-daemon.%s", user))
}
func usage() {
fmt.Fprintf(os.Stderr,
"Usage: %s [-s] [-f=<format>] [-in=<path>] [-sock=<type>] [-addr=<addr>]\n"+
" <command> [<args>]\n\n",
os.Args[0])
fmt.Fprintf(os.Stderr,
"Flags:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr,
"\nCommands:\n"+
" autocomplete [<path>] <offset> main autocompletion command\n"+
" exit terminate the gocode daemon\n")
}
func main() {
flag.Usage = usage
flag.Parse()
if *g_is_server {
doServer()
} else {
doClient()
}
}