aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-05-20 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-05-20 20:20:20 +0200
commit71a282d7623f8e95463d72aea405644cb1fdbdd2 (patch)
tree123057ab21de94d52b23a6f8f3be89375eb55100
parentmore reading (diff)
downloadhardflip-71a282d7623f8e95463d72aea405644cb1fdbdd2.tar.gz
hardflip-71a282d7623f8e95463d72aea405644cb1fdbdd2.tar.bz2
hardflip-71a282d7623f8e95463d72aea405644cb1fdbdd2.tar.xz
hardflip-71a282d7623f8e95463d72aea405644cb1fdbdd2.tar.zst
hardflip-71a282d7623f8e95463d72aea405644cb1fdbdd2.zip
cli opts letsgo
-rw-r--r--Makefile2
-rw-r--r--src/c_hardflip.go14
-rw-r--r--src/c_utils.go25
3 files changed, 40 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 220a375..586dda7 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ DEST := /usr
.DEFAULT_GOAL := ${TARGET}
run: ${SRC}
- go run ${SRC_DIR}
+ go run ${SRC_DIR} -qwe
${TARGET}: ${SRC}
go build -o ${TARGET} ${SRC_DIR}
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index dd3dd10..87979e9 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -51,6 +51,8 @@
package main
+import "os"
+
// the main data structure, holds up everything important
type HardData struct {
litems *ItemsList
@@ -69,6 +71,18 @@ type HardData struct {
}
func main() {
+ if len(os.Args) > 1 {
+ switch os.Args[1] {
+ case "-v",
+ "--version":
+ c_print_version()
+ case "-h",
+ "--help":
+ c_print_help()
+ default:
+ c_not_an_arg(os.Args[1])
+ }
+ }
data_dir := c_get_data_dir(nil)
i_ui(data_dir)
}
diff --git a/src/c_utils.go b/src/c_utils.go
index d95ac5a..af80772 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -233,3 +233,28 @@ func c_reverse_string(str string) string {
}
return string(runes)
}
+
+// prints the version and exits
+func c_print_version() {
+ fmt.Println("hf " + VERSION + " - " + VERSION_NAME)
+ os.Exit(0)
+}
+
+// prints the help and exits
+func c_print_help() {
+ fmt.Println(`Usage:
+ hf [options]
+
+Options:
+ -h, --help Prints this help menu
+ -v, --version Prints the version number and name
+
+Report bugs to <rbo@gmx.us>`)
+ os.Exit(0)
+}
+
+// wrong argument and exit
+func c_not_an_arg(arg string) {
+ fmt.Println("hf: Unknown argument " + arg)
+ os.Exit(1)
+}