Features
- simple, annotation driven model로 custom command 작성
- command 플러그인 전략(?)에 Spring Boot 자동 설정 사용
- tab 자동완성, 터미널 색칠, script의 실행
- command prompt, shell history, 실행 결과와 에러의 관리 및 커스터마이징
- bean validation API와의 통합
- clear, help, exit등 build-in commands 제공
- ascii art, formatting 정렬, fancy borders 등등등
<dependency> <groupId>org.springframework.shell</groupId> <artifactId>spring-shell-starter</artifactId> <version>2.0.1.RELEASE</version> </dependency>
┌──->──┐ | org.springframework.shell.result.ResultHandlerConfig └──<-──┘
임시 해결
spring.main.allow-circular-references= true
Command Examples
@ShellComponent public class MyCommands { @ShellMethod("Add two integers together.") public int add(int a, int b) { return a + b; } }
shell:>add 1 2 3
@ShellComponent public class TranslationCommands { private final TranslationService service; @Autowired public TranslationCommands(TranslationService service) { this.service = service; } @ShellMethod("Translate text from one language to another.") public String translate( @ShellOption String text, @ShellOption (defaultValue = "en_US") Locale from, @ShellOption Locale to ) { return service.translate(text, from, to); } } @Service public class TranslationService { public String translate(String text, Locale from, Locale to) { if (text.equals("Hello World!") && from.getLanguage().equals("en") && to.getLanguage().equals("ko")) { return "안녕 세상!"; } return "implementing..."; } }
shell:>translate "Hello World!" 안녕 세상! shell:>translate "Hello" --to fr_FR implementing...