-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.go
55 lines (47 loc) · 1.11 KB
/
common.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
package main
import (
"os"
"strings"
"github.com/urfave/cli/v2"
)
const wdprefix = "# wd="
var trimPathPrefix = os.Getenv("TRIM_CWD_PREFIX")
func trimPath(p string) string {
return strings.TrimPrefix(p, trimPathPrefix)
}
// ---
var commonConfig struct {
print, nowd, collect, apply bool
dir string
}
var commonFlags = []cli.Flag{
&cli.StringFlag{
Name: "dir",
Aliases: []string{"d"},
Destination: &commonConfig.dir,
Usage: "set working directory",
},
&cli.BoolFlag{
Name: "print",
Aliases: []string{"p"},
Destination: &commonConfig.print,
Usage: "print each processed line or file path",
},
&cli.BoolFlag{
Name: "nowd",
Destination: &commonConfig.nowd,
Usage: "no wd comment",
},
&cli.BoolFlag{
Name: "collect",
Aliases: []string{"c"},
Destination: &commonConfig.collect,
Usage: "collect data as specified by collect flags",
},
&cli.BoolFlag{
Name: "apply",
Aliases: []string{"a"},
Destination: &commonConfig.apply,
Usage: "apply changes as specified by apply flags",
},
}