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
Modifier and TypeClassDescriptionstatic class
Result from a path scanning.static class
Class defining configuration for path search.static interface
Context forPathSearch
.static class
Holder class keepingPath
andSearchMatchResult
.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_UNICODE, OPERATION_UP
-
Constructor Summary
ConstructorDescriptionPathSearch
(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 void
bindKeyMap
(org.jline.keymap.KeyMap<String> keyMap) Bind key map.getThisContext
(ComponentContext<?> context) Gets a real component context using common this trick.protected boolean
read
(org.jline.keymap.BindingReader bindingReader, org.jline.keymap.KeyMap<String> keyMap, PathSearch.PathSearchContext context) Read input.protected Path
resolvePath
(String path) Resolves aPath
from a given rawpath
.void
setPathProvider
(Function<String, Path> pathProvider) Sets a path provider.Methods inherited from class org.springframework.shell.component.support.AbstractTextComponent
getName, runInternal
Methods 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:AbstractComponent
Bind key map.- Overrides:
bindKeyMap
in classAbstractTextComponent<Path,
PathSearch.PathSearchContext>
-
getThisContext
Description copied from class:AbstractComponent
Gets a real component context using common this trick.- Specified by:
getThisContext
in 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:AbstractComponent
Read input.- Specified by:
read
in 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 aPath
from a given rawpath
.- Parameters:
path
- the raw path- Returns:
- a resolved path
-