Class PathSearch
java.lang.Object
org.springframework.shell.component.support.AbstractComponent<C>
org.springframework.shell.component.support.AbstractTextComponent<Path,PathSearch.PathSearchContext>
org.springframework.shell.component.PathSearch
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ResourceLoaderAware
Component resolving
Path based on base path and optional search term.
User is expected to type a base path and then delimited by space and a search
term.
Based on algorithms i.e. from https://github.com/junegunn/fzf and other
sources.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResult from a path scanning.static classClass defining configuration for path search.static interfaceContext forPathSearch.static classHolder class keepingPathandSearchMatchResult.Nested classes/interfaces inherited from class org.springframework.shell.component.support.AbstractTextComponent
AbstractTextComponent.BaseTextComponentContext<T,C extends AbstractTextComponent.TextComponentContext<T, C>>, AbstractTextComponent.TextComponentContext<T, C extends AbstractTextComponent.TextComponentContext<T, C>> -
Field Summary
Fields inherited from class org.springframework.shell.component.support.AbstractComponent
OPERATION_BACKSPACE, OPERATION_CHAR, OPERATION_DOWN, OPERATION_EXIT, OPERATION_SELECT, OPERATION_UP -
Constructor Summary
ConstructorsConstructorDescriptionPathSearch(org.jline.terminal.Terminal terminal) PathSearch(org.jline.terminal.Terminal terminal, String name) PathSearch(org.jline.terminal.Terminal terminal, String name, PathSearch.PathSearchConfig config) PathSearch(org.jline.terminal.Terminal terminal, String name, PathSearch.PathSearchConfig config, Function<PathSearch.PathSearchContext, List<org.jline.utils.AttributedString>> renderer) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindKeyMap(org.jline.keymap.KeyMap<String> keyMap) Bind key map.getThisContext(ComponentContext<?> context) Gets a real component context using common this trick.protected booleanread(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, PathSearch.PathSearchContext context) Read input.protected PathresolvePath(String path) Resolves aPathfrom a given rawpath.voidsetPathProvider(Function<String, Path> pathProvider) Sets a path provider.Methods inherited from class org.springframework.shell.component.support.AbstractTextComponent
getName, runInternalMethods inherited from class org.springframework.shell.component.support.AbstractComponent
addPostRunHandler, addPreRunHandler, getTemplateExecutor, getTerminal, hasTty, loop, render, renderTemplateResource, run, runPostRunHandlers, runPreRunHandlers, setPrintResults, setRenderer, setResourceLoader, setTemplateExecutor, setTemplateLocation
-
Constructor Details
-
PathSearch
public PathSearch(org.jline.terminal.Terminal terminal) -
PathSearch
-
PathSearch
public PathSearch(org.jline.terminal.Terminal terminal, String name, PathSearch.PathSearchConfig config) -
PathSearch
public PathSearch(org.jline.terminal.Terminal terminal, String name, PathSearch.PathSearchConfig config, Function<PathSearch.PathSearchContext, List<org.jline.utils.AttributedString>> renderer)
-
-
Method Details
-
bindKeyMap
Description copied from class:AbstractComponentBind key map.- Overrides:
bindKeyMapin classAbstractTextComponent<Path,PathSearch.PathSearchContext>
-
getThisContext
Description copied from class:AbstractComponentGets a real component context using common this trick.- Specified by:
getThisContextin classAbstractComponent<PathSearch.PathSearchContext>- Parameters:
context- the context- Returns:
- a component context
-
read
protected boolean read(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, PathSearch.PathSearchContext context) Description copied from class:AbstractComponentRead input.- Specified by:
readin classAbstractComponent<PathSearch.PathSearchContext>- Parameters:
bindingReader- the binding readerkeyMap- the key mapcontext- the context- Returns:
- true if read is complete, false to stop
-
setPathProvider
Sets a path provider.- Parameters:
pathProvider- the path provider
-
resolvePath
Resolves aPathfrom a given rawpath.- Parameters:
path- the raw path- Returns:
- a resolved path
-