diff options
author | joe <rbo@gmx.us> | 2025-08-28 10:39:42 +0200 |
---|---|---|
committer | joe <rbo@gmx.us> | 2025-08-28 10:39:42 +0200 |
commit | 8a58c7c57fef3f2a33faef07ecfebc85ed442877 (patch) | |
tree | e92a87f0daa1b837ef2894320ccd338849309346 /src/c_utils.go | |
parent | fuck it work so well (diff) | |
download | hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.gz hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.bz2 hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.xz hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.zst hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.zip |
n option good
Diffstat (limited to 'src/c_utils.go')
-rw-r--r-- | src/c_utils.go | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/c_utils.go b/src/c_utils.go index af6b4af..839d6c8 100644 --- a/src/c_utils.go +++ b/src/c_utils.go @@ -54,6 +54,7 @@ package main import ( "bytes" "errors" + "flag" "fmt" "io" "os" @@ -254,10 +255,9 @@ func c_print_help() { fmt.Println(`Usage: hf [options] -Options: - -h, --help Prints this help - -v, --version Prints the version number and name - +Options:`) + flag.PrintDefaults() + fmt.Println(` Report bugs to <rbo@gmx.us>`) os.Exit(0) } @@ -268,15 +268,17 @@ func c_not_an_arg(arg string) { os.Exit(1) } -func c_cli_opts(arg string) { - switch arg { - case "-v", - "--version": - c_print_version() - case "-h", - "--help": +func c_cli_opts() (bool, bool) { + h := flag.Bool("h", false, "print this help") + n := flag.Bool("n", false, "disable loop mode") + s := flag.Bool("s", false, "search-only mode (implies -n)") + v := flag.Bool("v", false, "print the version number and name") + flag.Parse() + if *h == true { c_print_help() - default: - c_not_an_arg(os.Args[1]) } + if *v == true { + c_print_version() + } + return *n, *s } |