Commit Graph

141 Commits

Author SHA1 Message Date
github-actions[bot]
8572eeef93 Next development version 2023-04-11 17:35:48 +00:00
Janne Valkealahti
78faeac86a Fix build with jdk8
- Remove non jdk8 code used in #694
2023-04-06 07:18:53 +01:00
Janne Valkealahti
041cb30eb0 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.
- Fixes #694
2023-04-02 14:37:08 +01:00
Janne Valkealahti
de08935b92 Fix ConfirmationInput template message
- Fix confirmation-input-default.stg to use correct style
  names in format.
- Backport #690
- Fixes #692
2023-03-17 08:43:52 +00:00
Simon Verhoeven
3c090848bf Rename setMaskCharater to setMaskCharacter
- Backport #686
- Fixes #689
2023-03-12 16:12:28 +00:00
github-actions[bot]
b4f2598417 Next development version 2023-02-27 17:26:44 +00:00
Janne Valkealahti
7ec5c194ff 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 #669
2023-02-18 14:21:08 +00:00
Janne Valkealahti
3c44c7c976 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 #653
2023-02-01 09:43:36 +00:00
Janne Valkealahti
ca76a63c30 CommandRegistration should return same options
- Cache created CommandOption(s) to return same instance.
- Backport #648
- Fixes #649
2023-01-28 17:50:45 +00:00
github-actions[bot]
61ab2de48c Next development version 2023-01-24 09:28:38 +00:00
Janne Valkealahti
5c52fbe373 Polish 2023-01-20 16:11:42 +00:00
Janne Valkealahti
1bc26c7e17 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.
- Backport #630
- Fixes #631
2023-01-19 17:34:43 +00:00
Janne Valkealahti
b853112e0b 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.
- Backport #622
- Fixes #623
2023-01-16 21:03:47 +00:00
Janne Valkealahti
7c91782841 Revisit positional arguments
- Add better mapping logic
- Add better type conversion
- More docs for arity and positional option configuration
- Backport #616
- Fixes #617
2023-01-13 17:56:24 +00:00
Janne Valkealahti
4381c2423e Handle arity errors
- Introduce new error TooManyArgumentsOptionException
  and NotEnoughArgumentsOptionException.
- Parser not tracks arity min/max and imposes
  if num of option arguments.
- Backport #614
- Fixes #615
- Original commit this sources had some additional changes
  which is not possible to merge.
2023-01-13 17:53:54 +00:00
github-actions[bot]
8179401268 Next development version 2023-01-10 14:47:40 +00:00
Janne Valkealahti
38acd79b83 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.
- Backport #601
- Backport #602
- Fixes #603
- Fixes #604
2023-01-07 09:08:15 +00:00
Janne Valkealahti
800e249b98 Fix NPE
- Backport #593
- Fixes #598
2023-01-01 15:12:48 +00:00
guang384
7a6d457e71 Wraps ExtendedArgumentList into CompletingParsedLine prevent WARNING during startup.
- Idea/hack copied from jline LineReaderImpl
- Backport #526
- Fixes #594
2022-12-27 15:34:41 +00:00
github-actions[bot]
14aa6f1703 Next development version 2022-12-01 16:10:00 +00:00
Janne Valkealahti
df19da0dde Method execution should not error without value
- Do npe check when getting class type out from
  incoming value.
- Backport #572
- Fix #573
2022-11-22 07:53:48 +00:00
Janne Valkealahti
bc0b4a13df 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.
- Backport #567
- Fixes #570
2022-11-18 07:28:07 +00:00
github-actions[bot]
3e5eac7008 Next development version 2022-10-24 06:52:51 +00:00
Janne Valkealahti
27f8802ebc 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.
- Backport #548
- Fixes #549
2022-10-14 06:44:35 +01:00
github-actions[bot]
685af2e3da Next development version 2022-10-04 13:54:37 +00:00
Janne Valkealahti
2cf712328c Fix next handling in ComponentFlow
- This fixes a bug where returning null from a next()
  didn't stop a flow.
- Backport #510
- Fixes #513

(cherry picked from commit 7c4700b7b5)
2022-08-22 16:30:52 +01:00
Janne Valkealahti
9087692999 Next development version 2022-08-19 14:39:33 +01:00
Janne Valkealahti
225f3e9f71 Polish javadocs
(cherry picked from commit eb82af42ed)
2022-08-18 08:34:58 +01:00
Janne Valkealahti
608b94ddfd Polish
- Backport main

(cherry picked from commit 891e1e17ef)
2022-08-16 15:10:41 +01:00
Janne Valkealahti
d6ab2e5f9b 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.
- Backport #495
- Fixes #498

(cherry picked from commit a143d25ffc)
2022-08-04 09:09:35 +01:00
Thibaut Gautier
703ffc8ec6 Fix ShellMethod not using context validator
(cherry picked from commit 23194d05e2)

- Backport #493
- Fixes #496
2022-08-02 09:57:16 +01:00
Janne Valkealahti
f826f29d77 Next development version 2022-07-23 15:15:17 +01:00
Janne Valkealahti
153f9e70a2 Fix tests
- Take2
- Relates to changes in #476
2022-07-20 10:10:58 +01:00
Janne Valkealahti
0fd67f2fad Fix tests
- Relates to changes in #476
2022-07-20 09:29:32 +01:00
Janne Valkealahti
d81e2614e3 Fix styling issue
- For title styling change from bold,fg:bright-white
  to bold which should work better with different
  terminal color settings as forcing it into bright white
  is a bad idea.
- Fixes #476
2022-07-20 09:01:05 +01:00
Drevsh
2862cc855e Add default selection to MultiItemSelector
- Added default selection to items
- Added correct styling for disabled but default selected item
- Added missing license header
- Added missing javadoc
- Added default selection to sample/doc code
2022-07-20 08:17:24 +01:00
Janne Valkealahti
5ba8e185bc Fix method argument without ShellOption
- For annotated methods with arguments, change default arity
  to zero with booleans and one everything else regardless
  if @ShellOption is defined or not.
- OptionArity.ZERO_OR_ONE had wrong upperbound value, change
  from MAX to 1.
- These modification should take us a bit closer to old
  shell functionality and what ShellOption documents for arity.
- For old functionality I'm referring to method
  `add(int a, int b)` and/or having @ShellOption and/or without
  arity setting.
- Fixes #446
2022-07-14 20:21:52 +01:00
Janne Valkealahti
32f77c1917 Rework completion interfaces
- Use same interface type in a generic interactive completions
  in a method level and option value level.
- Change CompletionResolver to have same function signature
  as with options and use CompletionContext to keep
  relevant information.
- Fixes #449
2022-07-06 09:02:06 +01:00
Janne Valkealahti
5eaa5dd093 Implement interactive completion
- This is a re-implementation of a interactive completion
  with breaking changes as it moves away from a direct use
  of a MethodParameter in favour of a CommandRegistration
  and its option definitions.
- Fixes #449
2022-06-28 14:10:23 +03:00
Janne Valkealahti
195d1d00ab Components can't use interactive mode without tty
- Adding a concept of no-tty which in this commit simply
  tracks DumbTerminal as jline creates that if there nothing
  better.
- For components without tty don't go to interaction loop.
- For new sample show that we can at least manually handle
  required option with a flow while command option is not
  required.
- Fixes #444
2022-06-15 09:56:14 +01:00
Janne Valkealahti
39c01fe00b Fix availability feature
- Bring back some missing functionality which got missing
  during the rework to new command model.
- Polish some classes.
- Restore origin sample.
- Add availability things into help templates and its
  representation model.
- Fixes #423
2022-06-14 11:51:50 +01:00
Janne Valkealahti
25721dd63d ConfirmationInput should have resultValue
- Add flow hooks to ConfirmationInput so that user
  is able to pass a flag from an options so that
  component can bypass interactive mode.
- Fixes #445
2022-06-13 09:27:16 +01:00
Janne Valkealahti
073cd8562c Rework themes support
- Add theme settings for figures.
- Settings for styles are now in it own class and
  ThemeSettings are wrapping those.
- Prefixed formatting string to have `style-` prefix.
- Templates can now use added `figures` dictionary which
  is resolved per activated theme.
- Create `dump` theme.
- New `ThemeActive` interface where default impl uses dump
  theme if `CI` or `NO_COLOR` env is set.
- Rework existing templates.
- Fixes #442
2022-06-10 13:56:21 +01:00
Janne Valkealahti
fa65a2308e Support option label
- This adds `label` to `CommandOption` which is then used
  in a Help instead of type.
- Fixes #424
2022-06-08 07:39:44 +01:00
Janne Valkealahti
8548828873 Polish contribution 2022-06-07 18:23:41 +01:00
Yubi Lee
38ce78434a Capturing CTRL+D EOF to exit the shell
* Capturing CTRL+D (EOF) to exit the shell
* replace junit to assertj
* fix hang on testing
2022-06-07 18:20:52 +01:00
Janne Valkealahti
7201a25567 Make ConversionService customisable
- Add ShellConversionServiceSupplier interface to define
  shell spesific ConversionService so that we don't
  get trouble with other services in boot.
- Fixes #435
2022-05-31 12:58:10 +01:00
Janne Valkealahti
3891a8b375 Add support for exit codes
- New configurations to CommandRegistration
- Re-using exit code concepts from boot
- Handling exit codes only in non-interactive mode
- Adding e2e commands and tests for better coverage
- Fixes #431
2022-05-31 07:49:50 +01:00
Janne Valkealahti
9779b5c729 Better errors with non-interactive mode
- Change how errors are printed for interactive
  vs non-interactive mode.
- This now changes behaviour so that stacktrace is printed
  if non-interactive mode is active so that user has a change
  to see the full error.
- Fixes #427
2022-05-27 09:09:21 +01:00
Janne Valkealahti
bd9ab62013 Rework help command
- Change help command output to get templated using
  model classes.
- Remove things around ParameterDescription as those are
  replaced with template classes.
- Fixes for native configs.
- For now availability and aliases are removed from
  help to get back in better form.
- Aliases has been partly introduced to structure.
- Fixes #422
2022-05-26 07:45:35 +01:00