Commit Graph

743 Commits

Author SHA1 Message Date
Janne Valkealahti
c91db3547d Upgrade spring-boot 3.0.3
- Fixes #661
2023-02-24 08:53:29 +00:00
Janne Valkealahti
3eeccd33be Rename command registration doc files 2023-02-23 09:57:40 +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
edfe67c00d Test terminal can set dimensions
- ShellTest now has fields which can be used to
  change terminal default widht/height.
- Backed by properties so can be used with
  `spring.shell.test.terminal-width` and
  `spring.shell.test.terminal-height`.
- Backport #656
- Fixes #659
2023-02-05 15:25:54 +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
1a1ddaadc7 Reorganise e2e samples
- Backport #642
- Fixes #643
2023-01-26 14:19:50 +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
d7f0459874 Change workflows for new branch 2023-01-24 12:34:26 +00:00
github-actions[bot]
bd7f5b882c Next development version 2023-01-24 10:23:23 +00:00
Janne Valkealahti
d44d0c3016 Update next version workflow 2023-01-23 11:32:14 +00:00
Janne Valkealahti
ae3af74b20 Update release workflow 2023-01-23 11:04:07 +00:00
Janne Valkealahti
fb1616e0c6 Polish 2023-01-20 16:09:21 +00:00
Janne Valkealahti
df9c5b5483 Upgrade spring-boot 3.0.2
- Fixes #619
2023-01-20 09:54:24 +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
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
90010a94ea Fix e2e tests
- As one command name was changed
2023-01-16 21:12:17 +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
6461a755d5 Add issue handler workflow
- Handle triage for new issues
- Handle backport issues
2023-01-12 10:43:10 +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
206da7463b Upgrade spring-boot 3.0.1
- Fixes #596
2022-12-27 16:04:46 +00:00
Janne Valkealahti
b98cb4926d Fix typo
- Relates #579
2022-12-08 10:02:46 +00:00
Janne Valkealahti
83e906d2e7 Document writing to console
- Relates #579
2022-12-08 09:51:59 +00:00
Janne Valkealahti
e5570ae62c Add search algo docs
- Relates #579
2022-12-06 09:00:24 +00:00
Janne Valkealahti
74c04a4964 Polish getting started
- Relates #579
2022-12-05 13:59:37 +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
b555148ce9 Fix assert in flow e2e test
- Fix assert by checking plain ">" if env CI variable is not set.
- Fixes #576
2022-11-30 17:27:48 +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
2bfcf99e96 Make Terminal configurable
- Add TerminalCustomizer which can be used to customise
  TerminalBuilder before instance from it is build.
- Fixes #516
2022-11-29 12:21:24 +00:00
Janne Valkealahti
452145264a Register option without prefix
- While option should be defined i.e. using "--arg", discover
  prefix from ShellMethod#prefix and use that if just "arg"
  is defined.
- Fixes #575
2022-11-26 15:08:07 +00:00
Janne Valkealahti
a900fa4977 Fix e2e tests
- Due to changes in #567 e2e tests started to fail as
  args where passed with spaces instead of args array.
- Fix all args use so that spawn underneath uses
  plain array with proper args.
2022-11-25 09:03:20 +00:00
Janne Valkealahti
a6b84372b2 Upgrade spring-boot 3.0.0
- Fixes #574
2022-11-24 17:56:30 +00:00
Janne Valkealahti
331df77ed8 More docs for option types
- Relates #558
2022-11-23 09:28:55 +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
57fac23bfc Upgrade graal 22.3 in workflows 2022-11-16 07:04:13 +00:00
Janne Valkealahti
217b9b7079 Use @AutoConfiguration
- Replace from @Configuration to @AutoConfiguration as that is now
  recommended by boot.
- Fixes #565
2022-11-15 08:30:17 +00:00