summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-05-17 02:31:10 +0200
committerewy <ewy0@protonmail.com>2026-05-17 02:33:16 +0200
commit7585a488b7b1e1812f7ebf50107139e2fd65f035 (patch)
tree921dd87ca8b5583abe4ebfe1474e1b02fbb7365f
parent45d1755e9f28853186613e97b034c2020f9d98e4 (diff)
add handmade help pageHEADmaster
-rw-r--r--flags/flags.go1
-rw-r--r--help/help.go13
-rw-r--r--help/help.txt35
-rw-r--r--main.go2
-rw-r--r--modes.go5
5 files changed, 56 insertions, 0 deletions
diff --git a/flags/flags.go b/flags/flags.go
index d8ac537..7920c41 100644
--- a/flags/flags.go
+++ b/flags/flags.go
@@ -3,6 +3,7 @@ package flags
import "github.com/spf13/pflag"
var (
+ Help = pflag.Bool("help", false, "print help information")
Profile = pflag.Bool("profile", false, "enable profiling")
// Here makes pik run the target at the current location instead of in its source directory
Here = pflag.BoolP("here", "h", false, "run target in current directory instead of source location")
diff --git a/help/help.go b/help/help.go
new file mode 100644
index 0000000..c19ebeb
--- /dev/null
+++ b/help/help.go
@@ -0,0 +1,13 @@
+package help
+
+import (
+ _ "embed"
+ "github.com/ewy1/pik/spool"
+)
+
+//go:embed help.txt
+var content string
+
+func Echo() {
+ _, _ = spool.Print("%v", content)
+}
diff --git a/help/help.txt b/help/help.txt
new file mode 100644
index 0000000..e5f4e4d
--- /dev/null
+++ b/help/help.txt
@@ -0,0 +1,35 @@
+Usage: pik [OPTION]... [SOURCE] [TARGET] [ARG]...
+
+If no arguments are provided, the TUI will open.
+
+Otherwise, pik will attempt to run the $TARGET script in $SOURCE.
+
+OPTIONS:
+ --help
+ print this information
+ -a, --all
+ in addition to crawling, also load all cached sources
+ -h, --here
+ run in the current working directory instead of the source folder
+ -@, --at [LOCATION]
+ run at $LOCATION instead of the source folder
+ -s, --single
+ skip triggers (pre, post, final targets)
+ -d, --dry
+ instead of running targets, echo their command
+ -r, --root
+ prefix target command with sudo
+ -y, --yes
+ assume yes for yes/no prompts
+ --env [ENVTYPE] [--env [OTHER]]...
+ load environment files that look like they belong to this category
+ -v, --version
+ print pik version and exit
+ -l, --list
+ list all available sources and targets instead of doing anything interactive
+ -i, -inline
+ disable TUI alt screen
+ --edit
+ open the target in $EDITOR instead of running it
+ --install-completion
+ install completion in your shell rc file (bash or zsh currently supported)
diff --git a/main.go b/main.go
index 800232a..25b570e 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@ import (
"github.com/ewy1/pik/crawl"
"github.com/ewy1/pik/flags"
"github.com/ewy1/pik/git"
+ "github.com/ewy1/pik/help"
"github.com/ewy1/pik/indexers/pikdex"
"github.com/ewy1/pik/menu"
"github.com/ewy1/pik/model"
@@ -105,6 +106,7 @@ func mode[T any](list ModeMap[T], fire func(mode T) error) *int {
}
func pik() int {
+ pflag.Usage = help.Echo
pflag.Parse()
code := mode(uninitializedModes, func(mode func() error) error {
diff --git a/modes.go b/modes.go
index 1d651b6..ec599a6 100644
--- a/modes.go
+++ b/modes.go
@@ -4,6 +4,7 @@ import (
"errors"
"github.com/ewy1/pik/completion"
"github.com/ewy1/pik/flags"
+ "github.com/ewy1/pik/help"
"github.com/ewy1/pik/model"
"github.com/ewy1/pik/paths"
"github.com/ewy1/pik/run"
@@ -55,6 +56,10 @@ var uninitializedModes = ModeMap[func() error]{
flags.Completion: func() error {
return completion.Echo()
},
+ flags.Help: func() error {
+ help.Echo()
+ return nil
+ },
}
// statelessModes are program modes which do not require state to operate.