-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynconf.go
69 lines (55 loc) · 1.23 KB
/
dynconf.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
69
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"fmt"
"os"
"strings"
"github.com/hahnjo/dynconf/internal"
)
const usage = `
Usage: dynconf command [arguments]
The commands are:
apply Apply a recipe and commit the result
check Validate a recipe
show Apply a recipe and output the result
help Print this help message
version Show version information
`
const version = `
DynConf 1.1.2
Copyright (C) 2018 - 2019 Jonas Hahnfeld
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions.
See COPYING or above link for defails.
`
func printUsage() {
fmt.Println(strings.TrimSpace(usage))
}
func printVersion() {
fmt.Println(strings.TrimSpace(version))
}
func main() {
args := os.Args[1:]
if len(args) == 0 {
printUsage()
os.Exit(1)
}
switch args[0] {
case "apply":
internal.Apply(args[1:])
case "check":
internal.Check(args[1:])
case "show":
internal.Show(args[1:])
case "help":
printUsage()
case "version":
printVersion()
default:
fmt.Fprintf(os.Stderr, "unknown command: %s\n\n", args[0])
printUsage()
os.Exit(1)
}
os.Exit(0)
}