Commit Graph

163 Commits

Author SHA1 Message Date
MJ Gallego
2cb0f115c6 Completion proposal support for complete jline parameter
- to allow completing single argument with multiple tab clicks,
  for example file paths.
- Backport #512
- Fixes #835
2023-07-25 09:59:26 +01:00
Janne Valkealahti
eaa363b34c Add better support for modified option names
- Longnames in a command option if modified via
  name modifier didn't provide enough backmapping
  info for command execution experience being accurate.
- Add new getLongNamesModified() into CommandOption
  which is populated if name modifier is used.
- Add more hints in CommandExecution for modified
  option names.
- This should bring annotation
  and programmatic commands up to date.
- Backport #777
- Fixes #782
2023-06-19 13:02:12 +01:00
Janne Valkealahti
304cf4be54 Revert "ExtendedDefaultParser should not add empty arguments"
This reverts commit af7be311cd.

Relates #764
2023-06-12 09:07:52 +01:00
Janne Valkealahti
52eb6b1811 Add jna native hints for linux
- Need for libjnidispatch.so, CLibrary$termios
  and CLibrary$winsize.
- Backport #762
- Fixes #768
2023-06-07 15:57:24 +01:00
Janne Valkealahti
af7be311cd ExtendedDefaultParser should not add empty arguments
- Fixes issue when last "word" is within quotes and
  cursor is at the end of a line which caused empty
  "word" string in an argument list.
- This then caused i.e. string option to have a collection
  as an input(if no arity settings used) and via
  spring conversions a comma were added.
- Backport #763
- Fixes #764
2023-06-07 15:56:37 +01:00
Janne Valkealahti
08b16d5290 Add hints for Availability targets
- Annotate ShellComponent with @Reflective and use custom
  AvailabilityReflectiveProcessor to find possible method
  targets returning Availability.
- Backport #747
- Fixes #758
2023-06-01 21:22:19 +01:00
Janne Valkealahti
0b1ece8da6 Add input into ConfirmationInput
- Now displaying what user actually inputs
- Backport #740
- Fixes #746
2023-05-20 17:22:48 +01:00
Janne Valkealahti
cd9651eea8 Fix option type parsing
- In `CommandRegistration` add `ResolvableType` for `OptionSpec` giving
  more spesific handling of a type.
- In `CommandParser` handle source and target types so that we
  have generics with `List`, `Set` and arrays working better.
- In `HandlerMethodArgumentResolver` add better handling for
  `ConversionService` for generic types.
- In `StandardMethodTargetRegistrar` add better types via `ResolvableType`
  now that `CommandRegistration` support it.
- In `OptionConversionCommands` remove converter from `String` to `Set` as
  now things should work as is if generic in a `Set` has a converter.
- Backport #694
- Fixes #699
2023-04-02 14:43:18 +01:00
Janne Valkealahti
4416509a90 Fix ConfirmationInput template message
- Fix confirmation-input-default.stg to use correct style
  names in format.
- Backport #690
- Fixes #691
2023-03-17 08:42:51 +00:00
Simon Verhoeven
04c936223a Rename setMaskCharater to setMaskCharacter
- Backport #686
- Fixes #688
2023-03-12 16:10:38 +00:00
Janne Valkealahti
e469c148df Use correct type with set
- When target is set and only one option argument is given,
  we should not convert to list as user expects string to xxx
  Converter to work.
- This is how it used to work and previous changes caused
  regression.
- Bug is actually in an old parser and new parser works fine.
- Backport #667
- Fixes #670
2023-02-18 14:20:41 +00:00
Janne Valkealahti
3ed49d1bd6 Handle arg looking options better
- Now lexing better with valid options
- Only report unrecognised option with double dash
  as current parser don't have structure to do
  deeper analysis.
- Backport #651
- Fixes #652
2023-02-01 09:43:12 +00:00
Janne Valkealahti
88df6cc7b4 CommandRegistration should return same options
- Cache created CommandOption(s) to return same instance.
- Backport #648
- Fixes #650
2023-01-28 17:14:07 +00:00
Janne Valkealahti
1c4608fb89 OptionArity NONE value
- Backport #644
- Fixes #645
2023-01-27 09:42:16 +00:00
Janne Valkealahti
32fc72329b Define CommandExceptionResolver bean order
- CommandParserExceptionResolver uses default bean
  order -100.
- Backport #634
- Fixes #635
2023-01-25 17:59:49 +00:00
Janne Valkealahti
fb1616e0c6 Polish 2023-01-20 16:09:21 +00:00
Janne Valkealahti
624343ace2 Handle collection types in a parser
- Handle any option collection type so that list is generated for
  values, this then works well when actual type conversions happen.
- Fixes #630
2023-01-19 17:33:18 +00:00
Janne Valkealahti
25d249c28d Exclude ExitRequest from error handling
- Don't try to handle ExitRequest exception with error handling
  so that we're able to break out from a run loop with
  interactive shell.
- Fixes #624
2023-01-18 09:03:03 +00:00
Janne Valkealahti
6e1ca089d7 Replace parser string joining with list
- Issue in #622 is that its command type is `String` and internally
  some incoming arguments(it's List) were converted to String by
  joining with space. This caused one case with help command to get
  conversion via spring's ConversionService(CollectionToStringConverter)
  which joins by commas. That was we saw in failed example.
- Remove needed joins in CommandParser and let it just pass List which
  then works better with ConversionService.
- This then needs a `command` option type change from String to String[]
  which it really is as you should be able to give whole command as
  an argument.
- Fixes #622
2023-01-16 17:47:21 +00:00
Janne Valkealahti
a04091c08f Support modify option names
- New OptionNameModifier which is just a Function<String,String> to
  modify a name.
- Can be defined per option in CommandRegistration.
- Can be defined as global default as bean.
- Default implementation for common case types is enabled via boot's
  config props under spring.shell.option.naming.case-type
- Support facilities for camel, kebab, snake and pascal conversions.
- Fixes #621
2023-01-15 10:02:55 +00:00
Christian Niessner
448c507ce9 Allow Shell.input() to be overridden in subclasses
- the ssh-shell-spring-boot extensions needs to extend to override the Shell.input()
  method to handle the input provided via the SSH session properly
2023-01-13 18:05:35 +00:00
Janne Valkealahti
95e2829dc3 Revisit positional arguments
- Add better mapping logic
- Add better type conversion
- More docs for arity and positional option configuration
- Fixes #616
2023-01-13 15:11:38 +00:00
Janne Valkealahti
b10786814a Handle arity errors
- Introduce new error TooManyArgumentsOptionException
  and NotEnoughArgumentsOptionException.
- Parser not tracks arity min/max and imposes
  if num of option arguments.
- CommandParserExceptionResolver contains better error
  message handling for these containing more context
  for a user.
- Fixes #614
2023-01-12 11:26:20 +00:00
Janne Valkealahti
f91b255bda Create BuilderSupplier interface
- Fixes #607
2023-01-08 13:38:33 +00:00
Janne Valkealahti
9b4e347633 Add unrecognised option support
- This commit modifies CommandParser to better track positional parameters
  which previously used to go there for non-recognised options. Now using
  relatively dump logic of just checking if first positional parameter starts
  with '-' which indicates it's a candidate for a new `UnrecognisedOptionException`
  which then would give user an error "Unrecognised option '--xxx'" for example.
- Fixes #601
- Fixes #602
2023-01-07 08:58:40 +00:00
Janne Valkealahti
c7c7e42b8b Fix NPE
- Fixes #593
2023-01-01 15:11:07 +00:00
Janne Valkealahti
bf2692c70c Support exception handling with annotated methods
- New annotations ExceptionResolver and ExitCode
- New needed functionality is in classes ExceptionResolverMethodResolver
  and MethodCommandExceptionResolver.
- Hook these annotations with StandardMethodTargetRegistrar and Shell classes
- Fixes #597
2023-01-01 14:51:05 +00:00
Janne Valkealahti
f5d6bae117 Handle option void type
- There's been no explicit support having argument void type
  as you would not be able to use with annotation model but
  surely can be wrapped as Type with CommandRegistration.
- For now change CommandInfoModel so that it uses empty string
  which is i.e. expected in help options which are just
  used as flags.
- It's outside of this commit to change parser to fail if
  user gives an argument value for this type of options.
- Fixes #586
2022-12-05 09:30:06 +00:00
Janne Valkealahti
ef191e66f3 Add support for global help options
- Essentially this commit registeres on default `--help` and
  `-h` options to every command and execution short circuits
  in presense of help options to help command.
- Add Supplier<CommandRegistration.Builder> as a bean which
  can be autowired registration beans.
- Make this common bean customisable via CommandRegistrationCustomizer.
- Change StandardMethodTargetRegistrar to use supplier so that
  annotated commands gets common customizations.
- Change sample commands to use supplier.
- Add new group, spring.shell.help to config props.
- Docs changes
- Fixes #582
- Fixes #585
2022-12-04 17:23:25 +00:00
Janne Valkealahti
61ae11bf94 Method execution should not error without value
- Do npe check when getting class type out from
  incoming value.
- Fix #572
2022-11-22 07:47:52 +00:00
Janne Valkealahti
ee7a9da4aa Fix warnings
- Fix some potential NPE cases.
- Fix warnings for missing @Nullable
2022-11-19 15:08:49 +00:00
Janne Valkealahti
83fb5f71fc Re-quote whitespace
- NonInteractiveShellRunner has a trouble where incoming
  argument loses info about "quoted" string which is handled
  by OS terminal.
- Add re-quoting in presense of a whitespace so that
  jline parser can detect it correctly.
- Fixes #567
2022-11-18 07:26:37 +00:00
Janne Valkealahti
46505e8b72 Polish 2022-10-22 06:17:24 +01:00
Janne Valkealahti
092a169fce Polish 2022-10-21 12:29:47 +01:00
Janne Valkealahti
b215705d49 Fix line split logic
- Fix issues where shows patsh were not correctly truncated
- Relates #556
2022-10-21 11:59:23 +01:00
Janne Valkealahti
4bab975ecf Add PathSearch component
- New PatchSearch component
- Allow user to define base directory for search
- Show (using single select list) search results
- Allow user to define search string
- Implement algorithms(start with exact-match and fuzzy-match) from fuzzy search tool (fzf)
- Sample "component path search" and change "component path" to "component path input"
- Fixes #556
2022-10-19 06:44:11 +01:00
Janne Valkealahti
3021704c29 Support hidden commands
- CommandRegistration now has a structure to define
  it beind hidden
- Modify relevant parts to filter out hidden commands
- Essentially command is hidden from all other than
  command execution
- Sample in e2e tests
- Fixes #416
2022-10-18 14:51:44 +01:00
Janne Valkealahti
feba345f00 Component text can be truncated
- BaseComponentContext has new field terminalWidth.
- StringToStyleExpressionRenderer contains new format
  for "truncate-" prefixes and this is something
  what template can use to instruct max length based
  on terminal width.
- Change single/multi selectors to use this feature.
- Fixes #543
2022-10-14 17:16:51 +01:00
Janne Valkealahti
4c48017a97 Implement more flexible error handling
- Add exception handling around new interface CommandExceptionResolver
  which allows to define a chain of resolvers to process errors before
  exception is bubbled up to result handlers.
- Will be foundation to add more sophisticated error handling features
  compared to what spring itself have for rest layer.
- Resolver returns CommandHandlingResult holder which further can be
  used to make a choice what to print into console and if spesific exit
  code should be used in non-interactive mode.
- Exception handling can be defined globally and per command giving
  a change for user to customise i.e. error thrown by parser.
- CommandParserExceptionResolver replaces CommandParserExceptionsExceptionResultHandler
  and provides more meaninful message for missing options.
- Fixes #503
2022-10-14 10:55:05 +01:00
Janne Valkealahti
3fe26025cd Process given values is a parser
- Modify CommandParser to convert given option value if its type is defined
- This change makes option default value to behave same as given value
  what comes for the actual value in a CommandContext.
- Fixes #548
2022-10-14 06:33:44 +01:00
Janne Valkealahti
6f220e2ea4 Fix deprecation in aot hints 2022-09-14 15:11:01 +01:00
guang384
37b0578c5d Wraps ExtendedArgumentList into CompletingParsedLine prevent WARNING during startup.
- Idea/hack copied from jline LineReaderImpl
- Fixes #526
2022-09-12 09:22:48 +01:00
Janne Valkealahti
68af0bb804 Move runtime hints from sample to core
- Relates #490
2022-09-07 09:58:25 +01:00
Janne Valkealahti
7c4700b7b5 Fix next handling in ComponentFlow
- This fixes a bug where returning null from a next()
  didn't stop a flow.
- Fixes #510
2022-08-22 16:30:08 +01:00
Janne Valkealahti
79350939a5 Handle When.MAYBE warning
- Add com.google.code.findbugs:jsr305 to compileOnly
  order to get rid of warnings.
2022-08-18 08:51:35 +01:00
Janne Valkealahti
eb82af42ed Polish javadocs 2022-08-18 08:34:13 +01:00
Janne Valkealahti
891e1e17ef Polish 2022-08-16 15:08:31 +01:00
Janne Valkealahti
c1c1da84db Remove maven build
- Relates #470
2022-08-16 12:48:04 +01:00
Janne Valkealahti
39c4519a3f Add gradle build files
- First set of changes for introduction of a gradle build.
- Relates #470
2022-08-16 10:30:15 +01:00
Janne Valkealahti
a143d25ffc Apply correct completion
- This commit fixes two issues.
- Firstly complete with correct option as existing bug was
  to wrongly always complete with first option which used
  wrong provider.
- Secondly filter out duplicate option proposals giving better
  result when options is already in place.
- Fixes #495
2022-08-04 09:08:11 +01:00