/
flags.go
68 lines (59 loc) · 1.42 KB
/
flags.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
)
// Flags.
var (
configDir = flag.String(
"config-dir",
getDefaultConfigDir(),
fmt.Sprintf(
`The directory to config files, by default $XDG_CONFIG_HOME/%s will be used`,
ConfigSubDir,
),
)
profile = flag.String(
"profile",
"default",
"If you have more than one google account, use this to contrrol which account to use",
)
noDaemon = flag.Bool(
"no-daemon",
false,
"By default mount command is run in daemon mode, use this flag to disable that behavior and run it in foreground instead",
)
)
// ConfigSubDir is the subdir under root config directory.
const ConfigSubDir = "godrive-fuse"
func getDefaultConfigDir() string {
configDir := os.Getenv("XDG_CONFIG_HOME")
if configDir != "" {
return filepath.Join(configDir, ConfigSubDir)
}
return filepath.Join(os.Getenv("HOME"), ".config", ConfigSubDir)
}
func setFlagUsage() {
flag.Usage = func() {
fmt.Fprintf(
flag.CommandLine.Output(),
`Usage:
%s [args] command [command args]
Commands:
help:
Show this message.
init:
Initialize the config file before first use.
mount [drive-directory] [local-directory]:
Mount the specified Drive directory to the local directory.
If drive-directory is omitted, root Google Drive directory will be used.
If both args are omitted, map all mountpoints defined in the config file instead.
Args:
`,
os.Args[0],
)
flag.PrintDefaults()
}
}