Skip to content

Commit 321675a

Browse files
committed
Add utility script to run samples
1 parent 275c220 commit 321675a

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

README.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@ You can find complete tutorials and sample applications in the `spring-shell-sam
8787
- https://github.com/spring-projects/spring-shell/tree/main/spring-shell-samples/spring-shell-sample-non-interactive[Non-interactive Spring Shell application]
8888
- https://github.com/spring-projects/spring-shell/tree/main/spring-shell-samples/spring-shell-sample-secure-input[Spring Shell application to demonstrate secure input]
8989

90+
A convenience script is provided to quickly launch any sample from the repository root:
91+
92+
[source,bash]
93+
----
94+
$>./run-sample.sh
95+
----
96+
97+
The script presents an interactive menu:
98+
99+
[source]
100+
----
101+
Spring Shell Samples
102+
====================
103+
104+
Select a sample to run:
105+
106+
1) hello-world — Simple greeting shell application
107+
2) non-interactive — Non-interactive sample (runs 'hi' and exits)
108+
3) petclinic — Spring PetClinic shell application
109+
4) secure-input — Secure input / password prompt sample
110+
5) spring-boot — Spring Boot-based shell application
111+
112+
Enter your choice [1-5]:
113+
----
114+
115+
Enter the number corresponding to the sample you want to run and press Enter. The appropriate Maven command will be executed automatically.
116+
90117
== Getting Help
91118
Are you having trouble with Spring Shell? We want to help!
92119

run-sample.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
echo "Spring Shell Samples"
6+
echo "===================="
7+
echo ""
8+
echo "Select a sample to run:"
9+
echo ""
10+
echo " 1) hello-world — Simple greeting shell application"
11+
echo " 2) non-interactive — Non-interactive sample (runs 'hi' and exits)"
12+
echo " 3) petclinic — Spring PetClinic shell application"
13+
echo " 4) secure-input — Secure input / password prompt sample"
14+
echo " 5) spring-boot — Spring Boot-based shell application"
15+
echo ""
16+
read -rp "Enter your choice [1-5]: " choice
17+
18+
case "$choice" in
19+
1)
20+
echo ""
21+
echo "Running: hello-world"
22+
./mvnw -pl org.springframework.shell:spring-shell-sample-hello-world \
23+
exec:java -Dexec.mainClass=org.springframework.shell.samples.helloworld.SpringShellApplication
24+
;;
25+
2)
26+
echo ""
27+
echo "Running: non-interactive"
28+
./mvnw -pl org.springframework.shell:spring-shell-sample-non-interactive \
29+
spring-boot:run -Dspring-boot.run.arguments=hi
30+
;;
31+
3)
32+
echo ""
33+
echo "Running: petclinic"
34+
./mvnw -pl org.springframework.shell:spring-shell-sample-petclinic \
35+
exec:java -Dexec.mainClass=org.springframework.shell.samples.petclinic.SpringShellApplication
36+
;;
37+
4)
38+
echo ""
39+
echo "Running: secure-input"
40+
./mvnw -pl org.springframework.shell:spring-shell-sample-secure-input \
41+
spring-boot:run
42+
;;
43+
5)
44+
echo ""
45+
echo "Running: spring-boot"
46+
./mvnw -pl org.springframework.shell:spring-shell-sample-spring-boot \
47+
spring-boot:run
48+
;;
49+
*)
50+
echo "Invalid choice: '$choice'. Please enter a number between 1 and 5." >&2
51+
exit 1
52+
;;
53+
esac

0 commit comments

Comments
 (0)