add a version subcommand

fix #63
This commit is contained in:
ppom
2023-12-31 12:00:00 +01:00
parent b834e02755
commit f6f26f283e
3 changed files with 21 additions and 4 deletions

View File

@ -72,7 +72,11 @@ func basicUsage() {
bold = "\033[1m"
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
# options:
@ -106,6 +110,9 @@ func basicUsage() {
` + 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
` + bold + `reaction version` + reset + `
# print version information
see usage examples, service configurations and good practices
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
var exampleConf string
func Main() {
func Main(version, commit string) {
if len(os.Args) <= 1 {
logger.Fatalln("No argument provided. Try `reaction help`")
basicUsage()
@ -125,6 +132,9 @@ func Main() {
case "help", "-h", "-help", "--help":
basicUsage()
case "version", "-v", "--version":
fmt.Printf("reaction version %v commit %v\n", commit, version)
case "example-conf":
subCommandParse(f, 0)
fmt.Print(exampleConf)