diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-04 16:06:59 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-04 16:19:16 +0900 |
| commit | 3f78d76da1f114d4e0e50f8ed3ed19fda980342d (patch) | |
| tree | 51e449291e2edf79f351a71220e734ce77224221 /src/options.go | |
| parent | 70c19ccf16a0f8ef2d0ef8ef44f69dd72aa210b1 (diff) | |
| download | fzf-3f78d76da1f114d4e0e50f8ed3ed19fda980342d.tar.gz | |
Allow accepting remote connections
Close #3498
# FZF_API_KEY is required for a non-localhost listen address
FZF_API_KEY=xxx fzf --listen 0.0.0.0:6266
Diffstat (limited to 'src/options.go')
| -rw-r--r-- | src/options.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/options.go b/src/options.go index b4f74e95..4176292f 100644 --- a/src/options.go +++ b/src/options.go @@ -118,7 +118,7 @@ const usage = `usage: fzf [options] --read0 Read input delimited by ASCII NUL characters --print0 Print output delimited by ASCII NUL characters --sync Synchronous search for multi-staged filtering - --listen[=HTTP_PORT] Start HTTP server to receive actions (POST /) + --listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /) --version Display version information and exit Environment variables @@ -334,7 +334,7 @@ type Options struct { PreviewLabel labelOpts Unicode bool Tabstop int - ListenPort *int + ListenAddr *string ClearOnExit bool Version bool } @@ -1833,10 +1833,13 @@ func parseOptions(opts *Options, allArgs []string) { case "--tabstop": opts.Tabstop = nextInt(allArgs, &i, "tab stop required") case "--listen": - port := optionalNumeric(allArgs, &i, 0) - opts.ListenPort = &port + given, addr := optionalNextString(allArgs, &i) + if !given { + addr = defaultListenAddr + } + opts.ListenAddr = &addr case "--no-listen": - opts.ListenPort = nil + opts.ListenAddr = nil case "--clear": opts.ClearOnExit = true case "--no-clear": @@ -1927,8 +1930,7 @@ func parseOptions(opts *Options, allArgs []string) { } else if match, value := optString(arg, "--tabstop="); match { opts.Tabstop = atoi(value) } else if match, value := optString(arg, "--listen="); match { - port := atoi(value) - opts.ListenPort = &port + opts.ListenAddr = &value } else if match, value := optString(arg, "--hscroll-off="); match { opts.HscrollOff = atoi(value) } else if match, value := optString(arg, "--scroll-off="); match { @@ -1958,10 +1960,6 @@ func parseOptions(opts *Options, allArgs []string) { errorExit("tab stop must be a positive integer") } - if opts.ListenPort != nil && (*opts.ListenPort < 0 || *opts.ListenPort > 65535) { - errorExit("invalid listen port") - } - if len(opts.JumpLabels) == 0 { errorExit("empty jump labels") } |
