summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-05-20 19:33:46 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-05-21 01:06:10 +0900
commit076b3d0a9af7e69c8e5232d49cfeeadcfd45e9ef (patch)
treeaf30be146de4df1b513b4145fa34ee3be5e6bbdf /src
parent7b0c9e04d381090ba2004f52fa7127cf2f4e3df4 (diff)
downloadfzf-076b3d0a9af7e69c8e5232d49cfeeadcfd45e9ef.tar.gz
Embed man page in the binary and show it on 'fzf --man'
Diffstat (limited to 'src')
-rw-r--r--src/functions.go2
-rw-r--r--src/options.go12
-rw-r--r--src/proxy.go2
-rw-r--r--src/terminal.go2
4 files changed, 14 insertions, 4 deletions
diff --git a/src/functions.go b/src/functions.go
index 8d29db74..59ca0bad 100644
--- a/src/functions.go
+++ b/src/functions.go
@@ -6,7 +6,7 @@ import (
"unsafe"
)
-func writeTemporaryFile(data []string, printSep string) string {
+func WriteTemporaryFile(data []string, printSep string) string {
f, err := os.CreateTemp("", "fzf-temp-*")
if err != nil {
// Unable to create temporary file
diff --git a/src/options.go b/src/options.go
index 3a6de009..6d228fe3 100644
--- a/src/options.go
+++ b/src/options.go
@@ -127,7 +127,6 @@ const Usage = `usage: fzf [options]
--with-shell=STR Shell command and flags to start child processes with
--listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /)
(To allow remote process execution, use --listen-unsafe)
- --version Display version information and exit
Directory traversal (Only used when $FZF_DEFAULT_COMMAND is not set)
--walker=OPTS [file][,dir][,follow][,hidden] (default: file,follow,hidden)
@@ -140,6 +139,11 @@ const Usage = `usage: fzf [options]
--zsh Print script to set up Zsh shell integration
--fish Print script to set up Fish shell integration
+ Help
+ --version Display version information and exit
+ --help Show this message
+ --man Show man page
+
Environment variables
FZF_DEFAULT_COMMAND Default command to use when input is tty
FZF_DEFAULT_OPTS Default options (e.g. '--layout=reverse --info=inline')
@@ -387,6 +391,7 @@ type Options struct {
Bash bool
Zsh bool
Fish bool
+ Man bool
Fuzzy bool
FuzzyAlgo algo.Algo
Scheme string
@@ -493,6 +498,7 @@ func defaultOptions() *Options {
Bash: false,
Zsh: false,
Fish: false,
+ Man: false,
Fuzzy: true,
FuzzyAlgo: algo.FuzzyMatchV2,
Scheme: "default",
@@ -1865,10 +1871,14 @@ func parseOptions(opts *Options, allArgs []string) error {
opts.Fish = false
opts.Help = false
opts.Version = false
+ opts.Man = false
}
for i := 0; i < len(allArgs); i++ {
arg := allArgs[i]
switch arg {
+ case "--man":
+ clearExitingOpts()
+ opts.Man = true
case "--bash":
clearExitingOpts()
opts.Bash = true
diff --git a/src/proxy.go b/src/proxy.go
index bbac0292..a1e8f805 100644
--- a/src/proxy.go
+++ b/src/proxy.go
@@ -98,7 +98,7 @@ func runProxy(commandPrefix string, cmdBuilder func(temp string) *exec.Cmd, opts
exports[idx] = fmt.Sprintf("export %s=%s", pair[0], escapeSingleQuote(pair[1]))
}
}
- temp := writeTemporaryFile(append(exports, command), "\n")
+ temp := WriteTemporaryFile(append(exports, command), "\n")
defer os.Remove(temp)
cmd := cmdBuilder(temp)
diff --git a/src/terminal.go b/src/terminal.go
index f50d7698..8f154dae 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -2840,7 +2840,7 @@ func replacePlaceholder(params replacePlaceholderParams) (string, []string) {
}
if flags.file {
- file := writeTemporaryFile(replacements, params.printsep)
+ file := WriteTemporaryFile(replacements, params.printsep)
tempFiles = append(tempFiles, file)
return file
}