mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-26 14:56:30 +00:00
Allow "--version" to be used as the argument to --query, --header, et al.
But why?
This commit is contained in:
parent
475469a2e7
commit
bbbcd780c9
@ -1742,12 +1742,20 @@ func postProcessOptions(opts *Options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func expectsArbitraryString(opt string) bool {
|
||||||
|
switch opt {
|
||||||
|
case "-q", "--query", "-f", "--filter", "--header", "--prompt":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// ParseOptions parses command-line options
|
// ParseOptions parses command-line options
|
||||||
func ParseOptions() *Options {
|
func ParseOptions() *Options {
|
||||||
opts := defaultOptions()
|
opts := defaultOptions()
|
||||||
|
|
||||||
for _, arg := range os.Args[1:] {
|
for idx, arg := range os.Args[1:] {
|
||||||
if arg == "--version" {
|
if arg == "--version" && (idx == 0 || idx > 0 && !expectsArbitraryString(os.Args[idx])) {
|
||||||
opts.Version = true
|
opts.Version = true
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user