parent
b834e02755
commit
f6f26f283e
2
Makefile
2
Makefile
@ -7,7 +7,7 @@ ip46tables: ip46tables.d/ip46tables.c
|
|||||||
gcc -static ip46tables.d/ip46tables.c -o ip46tables
|
gcc -static ip46tables.d/ip46tables.c -o ip46tables
|
||||||
|
|
||||||
reaction: app/* reaction.go go.mod go.sum
|
reaction: app/* reaction.go go.mod go.sum
|
||||||
CGO_ENABLED=0 go build -buildvcs=false .
|
CGO_ENABLED=0 go build -buildvcs=false -ldflags "-X main.version=`git tag --sort=v:refname | tail -n1` -X main.commit=`git rev-parse --short HEAD`"
|
||||||
|
|
||||||
reaction.deb: reaction ip46tables
|
reaction.deb: reaction ip46tables
|
||||||
chmod +x reaction ip46tables
|
chmod +x reaction ip46tables
|
||||||
|
14
app/main.go
14
app/main.go
@ -72,7 +72,11 @@ func basicUsage() {
|
|||||||
bold = "\033[1m"
|
bold = "\033[1m"
|
||||||
reset = "\033[0m"
|
reset = "\033[0m"
|
||||||
)
|
)
|
||||||
fmt.Print(bold + `reaction start` + reset + `
|
fmt.Print(
|
||||||
|
bold + `reaction help` + reset + `
|
||||||
|
# print this help message
|
||||||
|
|
||||||
|
` + bold + `reaction start` + reset + `
|
||||||
# start the daemon
|
# start the daemon
|
||||||
|
|
||||||
# options:
|
# options:
|
||||||
@ -106,6 +110,9 @@ func basicUsage() {
|
|||||||
` + bold + `reaction test-regex` + reset + ` REGEX LINE # test REGEX against LINE
|
` + bold + `reaction test-regex` + reset + ` REGEX LINE # test REGEX against LINE
|
||||||
cat FILE | ` + bold + `reaction test-regex` + reset + ` REGEX # test REGEX against each line of FILE
|
cat FILE | ` + bold + `reaction test-regex` + reset + ` REGEX # test REGEX against each line of FILE
|
||||||
|
|
||||||
|
` + bold + `reaction version` + reset + `
|
||||||
|
# print version information
|
||||||
|
|
||||||
see usage examples, service configurations and good practices
|
see usage examples, service configurations and good practices
|
||||||
on the ` + bold + `wiki` + reset + `: https://framagit.org/ppom/reaction-wiki
|
on the ` + bold + `wiki` + reset + `: https://framagit.org/ppom/reaction-wiki
|
||||||
`)
|
`)
|
||||||
@ -114,7 +121,7 @@ on the ` + bold + `wiki` + reset + `: https://framagit.org/ppom/reaction-wiki
|
|||||||
//go:embed example.yml
|
//go:embed example.yml
|
||||||
var exampleConf string
|
var exampleConf string
|
||||||
|
|
||||||
func Main() {
|
func Main(version, commit string) {
|
||||||
if len(os.Args) <= 1 {
|
if len(os.Args) <= 1 {
|
||||||
logger.Fatalln("No argument provided. Try `reaction help`")
|
logger.Fatalln("No argument provided. Try `reaction help`")
|
||||||
basicUsage()
|
basicUsage()
|
||||||
@ -125,6 +132,9 @@ func Main() {
|
|||||||
case "help", "-h", "-help", "--help":
|
case "help", "-h", "-help", "--help":
|
||||||
basicUsage()
|
basicUsage()
|
||||||
|
|
||||||
|
case "version", "-v", "--version":
|
||||||
|
fmt.Printf("reaction version %v commit %v\n", commit, version)
|
||||||
|
|
||||||
case "example-conf":
|
case "example-conf":
|
||||||
subCommandParse(f, 0)
|
subCommandParse(f, 0)
|
||||||
fmt.Print(exampleConf)
|
fmt.Print(exampleConf)
|
||||||
|
@ -5,5 +5,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app.Main()
|
app.Main(version, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Must be passed when building
|
||||||
|
// go build -ldflags "-X app.commit XXX -X app.version XXX"
|
||||||
|
version string
|
||||||
|
commit string
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user