@@ -6,7 +6,7 @@ This section describes how to use Spring Shell.
66
77[IMPORTANT]
88====
9- _Spring Shell 3 .x_ is a major rework to bring codebase up-to-date with
9+ _Spring Shell 2.1 .x_ is a major rework to bring codebase up-to-date with
1010existing _Spring Boot_ versions, adding new features and especially
1111making it work with _GraalVM_ which makes command-line applications much
1212more relevant on a java space. Moving to new major version also allows
@@ -888,9 +888,46 @@ working with non-interactive mode.
888888
889889Currently only implementation is for _bash_ which works with `bash` sub-command.
890890
891+ ==== Version
892+
893+ The `version` command shows existing _build_ and _git_ info by integrating into
894+ Boot's `BuildProperties` and `GitProperties` if those exists in a shell app.
895+ On default only version info is shown and other can be enabled via configuration
896+ options.
897+
898+ Settings are under `spring.shell.command.version` where you can use `enabled` to
899+ disable command and optionally define your own template with `template`. Options
900+ `show-build-artifact`, `show-build-group`, `show-build-name`, `show-build-time`,
901+ `show-build-version`, `show-git-branch`, `show-git-commit-id`,
902+ `show-git-short-commit-id` and `show-git-commit-time` can be used to control
903+ fields in a default template.
904+
905+ Template default to `classpath:template/version-default.st` and you can define
906+ your own, for example having:
907+
908+ ====
909+ [source]
910+ ----
911+ <buildVersion>
912+ ----
913+ ====
914+
915+ Which would simply output something like:
916+
917+ ====
918+ [source]
919+ ----
920+ X.X.X
921+ ----
922+ ====
923+
924+ Attributes added to default template rendering are `buildVersion`, `buildGroup`,
925+ `buildGroup`, `buildName`, `buildTime`, `gitShortCommitId`, `gitCommitId`,
926+ `gitBranch` and `gitCommitTime`.
927+
891928=== Interaction Mode
892929
893- Starting from _3 .x_ a build-in support has been added to distinguish between interactive
930+ Starting from _2.1 .x_ a build-in support has been added to distinguish between interactive
894931and non-interactive modes. This has been added so that it's easier to use shell as a
895932simple command-line tool without requiring customisation to accomplish that.
896933
@@ -908,7 +945,7 @@ shell when particular command is available.
908945[[native]]
909946=== Native Support
910947
911- Re-work with _3 .x_ brings in an experimental support for compiling shell application
948+ Re-work with _2.1 .x_ brings in an experimental support for compiling shell application
912949into _native_ application with _GraalVM_ and _spring-native_. As underlying _jline_
913950library works with _GraalVM_ most of a things should just work.
914951
@@ -937,6 +974,57 @@ Built-In Commands
937974----
938975====
939976
977+ [[styling]]
978+ === Styling
979+
980+ Starting with _2.1.x_ there is a support for centrally handling styling and theming.
981+ There is a default theme named _default_ which can be changed using property
982+ `spring.shell.theme.name`.
983+
984+ To create a new theme register new `Theme` bean with custom `ThemeSettings` where
985+ you can tweak styles.
986+
987+ ====
988+ [source, java]
989+ ----
990+ @Configuration
991+ static class CustomThemeConfig {
992+
993+ @Bean
994+ public Theme myTheme() {
995+ return new Theme() {
996+ @Override
997+ public String getName() {
998+ return "mytheme";
999+ }
1000+ @Override
1001+ public ThemeSettings getSettings() {
1002+ return new MyThemeSettings();
1003+ }
1004+ };
1005+ }
1006+ }
1007+
1008+ static class MyThemeSettings extends ThemeSettings {
1009+ }
1010+ ----
1011+ ====
1012+
1013+ `ThemeResolver` can be used to resolve styles if you want to create
1014+ _jline_ styled strings programmatically.
1015+
1016+ ====
1017+ [source, java]
1018+ ----
1019+ @Autowired
1020+ private ThemeResolver themeResolver;
1021+
1022+ String resolvedStyle = themeResolver.resolveTag(TAG_TITLE);
1023+ AttributedStyle style = themeResolver.resolveStyle(resolvedStyle);
1024+ ----
1025+ ====
1026+
1027+
9401028=== Customizing the Shell
9411029
9421030[[overriding-or-disabling-built-in-commands]]
@@ -1078,7 +1166,7 @@ various `ShellRunner` implementations where candidate will be picked up.
10781166
10791167[IMPORTANT]
10801168====
1081- This is a breaking change in `3 .x` as previous shell versions had an confusing
1169+ This is a breaking change in `2.1 .x` as previous shell versions had an confusing
10821170logic how `ApplicationRunner` instances were used. These changes were made
10831171to have a better support for interactive and non-interactive modes in a same
10841172shell application as it's convenient to fully work on command-line and still
0 commit comments