diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-06-04 15:48:38 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-06-04 17:50:46 +0900 |
| commit | 93bbb3032d1e7550dbabb2d450999cd434c60509 (patch) | |
| tree | f6b4331975184172b256c71335f5964bcddc77df /src/options.go | |
| parent | 4c83d8596d48acc106ffe62d50a55b3f9608c830 (diff) | |
| download | fzf-93bbb3032d1e7550dbabb2d450999cd434c60509.tar.gz | |
Add --tail=NUM to limit the number of items to keep in memory
Diffstat (limited to 'src/options.go')
| -rw-r--r-- | src/options.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go index 25bfd317..35784e5c 100644 --- a/src/options.go +++ b/src/options.go @@ -41,6 +41,7 @@ Usage: fzf [options] field index expressions -d, --delimiter=STR Field delimiter regex (default: AWK-style) +s, --no-sort Do not sort the result + --tail=NUM Maximum number of items to keep in memory --track Track the current selection when the result is updated --tac Reverse the order of the input --disabled Do not perform search @@ -421,6 +422,7 @@ type Options struct { Sort int Track trackOption Tac bool + Tail int Criteria []criterion Multi int Ansi bool @@ -2096,6 +2098,15 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { opts.Tac = true case "--no-tac": opts.Tac = false + case "--tail": + if opts.Tail, err = nextInt(allArgs, &i, "number of items to keep required"); err != nil { + return err + } + if opts.Tail <= 0 { + return errors.New("number of items to keep must be a positive integer") + } + case "--no-tail": + opts.Tail = 0 case "-i", "--ignore-case": opts.Case = CaseIgnore case "+i", "--no-ignore-case": @@ -2631,6 +2642,13 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { } else if match, value := optString(arg, "--jump-labels="); match { opts.JumpLabels = value validateJumpLabels = true + } else if match, value := optString(arg, "--tail="); match { + if opts.Tail, err = atoi(value); err != nil { + return err + } + if opts.Tail <= 0 { + return errors.New("number of items to keep must be a positive integer") + } } else { return errors.New("unknown option: " + arg) } |
