-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.go
52 lines (41 loc) · 1.15 KB
/
main.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
package main
import (
"fmt"
"os"
flags "github.com/jessevdk/go-flags"
)
// Options defines options supported by all subcommands
type Options struct {
IgnoreInlineComments bool `long:"ignore-inline-comments" description:"Ignore inline comments"`
}
var globalOpts = &Options{}
var (
version = "1.4.7"
buildDate = ""
commit = ""
)
func versionText() string {
msg := fmt.Sprintf("%-12s %s", "Version:", version)
if buildDate != "" {
msg += fmt.Sprintf("\n%-12s %s", "Built on:", buildDate)
}
if commit != "" {
msg += fmt.Sprintf("\n%-12s %s", "Git Commit:", commit)
}
return msg
}
func main() {
setCmd := NewINIFileSetCmd()
getCmd := NewINIFileGetCmd()
delCmd := NewINIFileDelCmd()
parser := flags.NewParser(globalOpts, flags.HelpFlag|flags.PassDoubleDash)
parser.LongDescription = versionText()
parser.AddCommand("set", "INI File Set", "Sets values in a INI file", setCmd)
parser.AddCommand("get", "INI FILE Get", "Gets values from a INI file", getCmd)
parser.AddCommand("del", "INI FILE Delete", "Deletes values from a INI file", delCmd)
_, err := parser.Parse()
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}