aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-08-28 10:39:42 +0200
committerjoe <rbo@gmx.us>2025-08-28 10:39:42 +0200
commit8a58c7c57fef3f2a33faef07ecfebc85ed442877 (patch)
treee92a87f0daa1b837ef2894320ccd338849309346 /src
parentfuck it work so well (diff)
downloadhardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.gz
hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.bz2
hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.xz
hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.tar.zst
hardflip-8a58c7c57fef3f2a33faef07ecfebc85ed442877.zip
n option good
Diffstat (limited to '')
-rw-r--r--src/c_defs.go2
-rw-r--r--src/c_hardflip.go6
-rw-r--r--src/c_utils.go28
-rw-r--r--src/i_ui.go5
4 files changed, 24 insertions, 17 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 916f19f..09b81f6 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -56,7 +56,7 @@ const (
STYLE_FILE_NAME = "colors.yml"
CONF_DIR_NAME = "hf"
DATA_DIR_NAME = "hf"
- VERSION = "v1.0.1"
+ VERSION = "v1.0.2"
VERSION_NAME = "wheelbite"
)
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 6c67305..d808792 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -71,9 +71,11 @@ type HardData struct {
}
func main() {
+ var n_opt, _ bool
+
if len(os.Args) > 1 {
- c_cli_opts(os.Args[1])
+ n_opt, _ = c_cli_opts()
}
data_dir := c_get_data_dir(nil)
- i_ui(data_dir)
+ i_ui(data_dir, n_opt)
}
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
}
diff --git a/src/i_ui.go b/src/i_ui.go
index e824908..277ac0a 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -783,7 +783,7 @@ func i_init_styles(ui *HardUI, styles HardStyle) {
type key_event_mode_func func(*HardData, *HardUI, tcell.EventKey) bool
-func i_ui(data_dir string) {
+func i_ui(data_dir string, no_loop bool) {
home_dir, _ := os.UserHomeDir()
ui := HardUI{}
opts := HardOpts{}
@@ -804,6 +804,9 @@ func i_ui(data_dir string) {
} else {
opts = c_get_options(conf_dir, &load_err)
}
+ if no_loop == true {
+ opts.Loop = false
+ }
styles := c_get_styles(conf_dir, &load_err)
i_init_styles(&ui, styles)
ui.s.SetStyle(ui.style[DEF_STYLE])