aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--Makefile2
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--man/hf.11
-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
8 files changed, 29 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 88597ab..2a74f28 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ DEST := /usr
.DEFAULT_GOAL := ${TARGET}
run: ${SRC}
- go run ${SRC_DIR}
+ go run ${SRC_DIR} -n
${TARGET}: ${SRC}
go build -o ${TARGET} ${SRC_DIR}
diff --git a/go.mod b/go.mod
index 2b6c152..a131274 100644
--- a/go.mod
+++ b/go.mod
@@ -4,6 +4,7 @@ go 1.25.0
require (
github.com/gdamore/tcell/v2 v2.9.0
+ github.com/jessevdk/go-flags v1.6.1
golang.org/x/term v0.34.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.33.4
diff --git a/go.sum b/go.sum
index 61a75d3..1cdc522 100644
--- a/go.sum
+++ b/go.sum
@@ -4,6 +4,8 @@ github.com/gdamore/tcell/v2 v2.9.0 h1:N6t+eqK7/xwtRPwxzs1PXeRWnm0H9l02CrgJ7DLn1y
github.com/gdamore/tcell/v2 v2.9.0/go.mod h1:8/ZoqM9rxzYphT9tH/9LnunhV9oPBqwS8WHGYm5nrmo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
+github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
diff --git a/man/hf.1 b/man/hf.1
index 8760e4f..6f21d20 100644
--- a/man/hf.1
+++ b/man/hf.1
@@ -77,4 +77,5 @@ Joe <rbo@gmx.us>
.IR ssh (1),
.IR xfreerdpd (1),
.IR gpg (1),
+.IR fzf (1),
.IR remmina (1)
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])