From 7585a488b7b1e1812f7ebf50107139e2fd65f035 Mon Sep 17 00:00:00 2001 From: ewy Date: Sun, 17 May 2026 02:31:10 +0200 Subject: add handmade help page --- flags/flags.go | 1 + help/help.go | 13 +++++++++++++ help/help.txt | 35 +++++++++++++++++++++++++++++++++++ main.go | 2 ++ modes.go | 5 +++++ 5 files changed, 56 insertions(+) create mode 100644 help/help.go create mode 100644 help/help.txt 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. -- cgit v1.3.1