abiosoft / ishell

Library for creating interactive cli applications.
MIT License
1.68k stars 195 forks source link

Provide input prefix completer function #118

Closed rhuss closed 5 years ago

rhuss commented 5 years ago

Currently, the Completer function which can be added to command only receives fully completed words as arguments.

For finer-granular control it would be awesome to add also the prefix added so far to the arguments list for the completer function. This would allow completions which depend on the current input, like ls /usr/loc + TAB does complete only on directories found in /usr starting with loc (so the completer function would need to know that the user typed in /usr/loc to perform this kind of dynamic completion.

For backwards compatibility it's probably out of scope to change the signature of https://github.com/abiosoft/ishell/blob/8b8aa74a85127192b469453a72fd7971b47481fb/command.go#L29, so I suggest to a new member CompleterWithPrefix.

abiosoft commented 5 years ago

https://github.com/abiosoft/ishell/pull/119