119 Commits

Author SHA1 Message Date
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
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
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
8c7b70b21e Better e2e tests coverage
- Add integration tests for e2e samples.
- Add some missing commands for new annotation system.
- Backport #654
- Fixes #655
2023-02-06 09:04:24 +00:00
Janne Valkealahti
1a1ddaadc7 Reorganise e2e samples
- Backport #642
- Fixes #643
2023-01-26 14:19:50 +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
56b9cb20ef Document String array option type
- Fixes #628
2023-01-19 11:32:37 +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
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
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
83e906d2e7 Document writing to console
- Relates #579
2022-12-08 09:51:59 +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
0899d414de Build linux sample with musl
- Change sample build to use musl on linux
- Optionally remove version from jar so that
  e2e tests don't need to use version in path.
- Add better matrix to e2e so that we're able to
  build on one OS and then test with others.
- Fixes #576
2022-11-30 15:39:10 +00:00
Janne Valkealahti
d3e897f6d9 Add base shell test system
- NOTE: very much wip and unstable
- This commit is a first step to provide boot style
  @ShellTest annotation
- New modules spring-shell-test and spring-shell-test-autoconfigure
- Focus is to autoconfigure context without shell runners so that
  we can create "sessions" and hook to configures jline terminal
  with custom in/out streams.
- Skeleton fork from jediterm to provide basic terminal emulation
  to part of a control amd escape characters working.
- ShellTestClient is a concept user can use to interact with a shell
  in a same way user would use a "real" shell.
- Fixes #489
2022-11-30 09:09:35 +00:00
Janne Valkealahti
331df77ed8 More docs for option types
- Relates #558
2022-11-23 09:28:55 +00:00
Janne Valkealahti
ea76e0d205 Change native build
- Align samples build with docs
- Relates #558
2022-10-22 06:45:02 +01:00
Janne Valkealahti
3e0ca620ea Upgrade spring-boot 3.0.0-RC1
- Fixes #557
2022-10-21 12:16:40 +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
226b081c1c Upgrade native-build-tools 0.9.14
- Update docs
- Fixes #540
2022-10-03 09:20:49 +01:00
Janne Valkealahti
f2009e2cb3 Move starter modules under starters
- Now all starters are kept under spring-shell-starters dir.
- Fixes #524
2022-09-08 13:12:12 +01:00
Janne Valkealahti
68af0bb804 Move runtime hints from sample to core
- Relates #490
2022-09-07 09:58:25 +01:00
Janne Valkealahti
146f9165ea Fix wrong jni fields in java.nio.Buffer 2022-09-07 08:51:01 +01:00
Janne Valkealahti
a79d2a6c53 Switch sample jni config programmatic
- Now generating jni-config.json via hints to test
  that side instead of having manually crafted file.
- Relates #490
2022-09-06 19:48:02 +01:00
Janne Valkealahti
a9a420df22 Switch to use implementation config
- Now switching to use implementation configuration as it
  works better with aot tooling.
- Relates #470
2022-09-06 19:39:14 +01:00
Janne Valkealahti
52baaa3f86 Use graal metadata repository
- New version 0.1.1 now enabled in sample.
- Remove hibernate validator hints as those are
  in metadata repo.
- Relates #490
2022-08-19 08:09:06 +01:00
Janne Valkealahti
310cbf84a0 Remove old spring-native sample config
- Relates #490
2022-08-19 08:05:17 +01:00
Janne Valkealahti
bb7afdf10f Configure build-info for sample
- e2e tests version command fails without build-info.
- Relates #470
2022-08-17 09:28:38 +01:00
Janne Valkealahti
fee09f9ff5 Integration native build to sample
- This adds a way to build native binary for a sample which
  were missed from original gradle work.
- Relates #470
2022-08-17 08:45: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
Janne Valkealahti
1ff802d8e0 Add recorded jni-config for windows in sample
- While out of a box *nix don't need spesific native config as is,
  windows is a different story as it needs jna/jansi stuff and i.e.
  jna needs jvm native things which doesn't work without correct
  graal configs.
- Relates #490
2022-07-29 16:24:40 +01:00
Janne Valkealahti
e193ca1d24 Upgrade to Boot 3.x
- For now port spring-native to framework config.
- 3rd party configs should go somewhere else.
- Fix changes from javax to jakarta.
- Change java settings as we now require jdk 17.
- Fixes #385
2022-07-24 08:07:14 +01:00
Janne Valkealahti
bff7a22b5e Next major development version 2022-07-23 15:57:21 +01:00
Janne Valkealahti
f826f29d77 Next development version 2022-07-23 15:15:17 +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
643b189fb8 Default boolean arg to false
- In a case where arg is given as boolean and with plain
  @ShellOption (user doesn't define defaults), configure
  arg not to be mandatory and with default value false.
- This brings this spesific case more close how it behave
  in older shell version.
- Having `@ShellOption boolean arg1` it now works as:
    my-shell:>e2e reg default-value-boolean3
    Hello false
    my-shell:>e2e reg default-value-boolean3 --arg1
    Hello true
    my-shell:>e2e reg default-value-boolean3 --arg1 false
    Hello false
    my-shell:>e2e reg default-value-boolean3 --arg1 true
    Hello true
- Fixes #461
2022-07-18 12:41:23 +03:00
Janne Valkealahti
06d9fd51b2 Fix alias usage in help command
- Add info about aliases into model structure used by help
  command templating.
- Add some tests to models.
- Change help commands list to group command and its aliases together.
- Change help command to show aliases.
- Fixes #458
- Fixes #426
2022-07-14 19:17:37 +03:00
Janne Valkealahti
2520e0681f Rework theme sample
- Rename class and commands.
- Changes mostly to make it easier to test things
  out manually when following theming docs.
- Relates #433
2022-07-04 09:53:50 +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