Open krader1961 opened 4 months ago
The methods are used in history walking mode to avoid loading the entire history into memory.
The methods are used in history walking mode to avoid loading the entire history into memory.
That is true for the implementation underlying store:prev-cmd
but not store:next-cmd
, AFAICT. The CLI store code calls the PrevCmd
method when it has not already cached the previous command relative to the current command history cursor. AFAICT it never calls the NextCmd
method.
Only the store:next-cmd
implementation calls the NextCmd
method, AFAICT. Also, both methods are essentially implementation details of the CLI command history traversal mechanism to skip identical commands. Which might be why the commands in the store
module that invokes them didn't get documented (obviously it could also be a simple oversight).
Regardless of the reason these commands are not documented I don't think they should be documented and the commands should be removed. Anyone wanting to examine the command history can use the store:cmds
and store:cmd
commands. It is not obvious what the value is in exposing the internal PrevCmd
and NextCmd
methods.
While working on my flat-file replacement for the Elvish daemon and BoltDB I noticed the
store:next-cmd
andstore:prev-cmd
commands are not documented.P.S., I only noticed this because I was exploring when the
type Store interface
methodNextCmd
(defined in pkg/store/storedefs/storedefs.go) was invoked. AFAICT it is only called by thestore:next-cmd
implementation. Which begs the question whether either command should even exist given that the user can simply get a list of all commands usingstore:cmds
and iterate through the list.