Comments (11)
Based on @jeffellin code, I created a spring-boot-starter-shell to make spring shell with spring-boot easy. https://github.com/linux-china/spring-boot-starter-shell
from spring-shell.
I would love this feature also - make it easy to bootstrap a spring-shell app with spring-boot. No shims or other hacks.
from spring-shell.
Agreed. Im looking to do the same for the same reasons.
from spring-shell.
What is it that is "nice" about Spring Shell that you can't do with Spring Boot (especially with the CLI)?
from spring-shell.
Well, for one isn't the Spring Boot CLI for developers, not end users of the applications built with Spring Boot? Secondly, if you are trying to build an application that has a shell as one of its primary interfaces, Spring Shell seems very appropriate if you are developing with Spring. My use case is building something like the mongo shell that has both a CLI and shell interface. For the CLI I'm using JCommander because it has very rich support (something that is missing in both Spring and Spring Boot). One of the commands was going to be "shell", which would drop me into a Spring Shell session. The integration point doesn't look very good since it wan't to take full control of the application context. Lastly, I considered using CRaSH but that seems to be more geared towards operational concerns and not primary users.
from spring-shell.
Spring Boot CLI as it is packaged and distributed for Spring Boot is for developers, but it's just a fairly thin layer that we use to bootstrap pluggable commands, so it could be used (or bits could be extracted) to make your task easier.
If I understand correctly, Spring Boot CLI is much closer to what you need as a building block since it already is a CLI and a shell (whereas Spring Shell is just a shell as far as I know). Spring Boot CLI also has no opinion whatsoever about how to build an ApplicationContext
so it won't get in your way at all there.
The Grails guys (cc @lhotari) are working on a command line / shell tool for Grails 3.0 as well, so it might be worth checking what they are doing too. I think it might even be based on Spring Boot, or at least contain some of the same code, so there is a good chance that we can extract a common framework for building such apps.
Is JCommander included with Spring Shell? We like JOpt in Spring Boot, and it seems pretty well suited to building a self-describing CLI, so maybe it's worth a look if you haven't tried it.
Agree that CRaSH is probably not the right vehicle.
from spring-shell.
Spring Boot CLI as it is packaged and distributed for Spring Boot is for developers, but it's just a fairly thin layer that we use to bootstrap pluggable commands, so it could be used (or bits could be extracted) to make your task easier.
Extracting the non-development aspects would be certainly welcomed. I would rather not pull in new dependencies like Groovy, etc. if they are not used / required.
If I understand correctly, Spring Boot CLI is much closer to what you need as a building block since it already is a CLI and a shell (whereas Spring Shell is just a shell as far as I know). Spring Boot CLI also has no opinion whatsoever about how to build an ApplicationContext so it won't get in your way at all there.
That sounds great, although its not clear how things are bootstrapped looking at https://github.com/spring-projects/spring-boot/blob/master/spring-boot-cli/src/main/java/org/springframework/boot/cli/SpringCli.java . I don't see how I would integrate with a custom application context.
The Grails guys (cc @lhotari) are working on a command line / shell tool for Grails 3.0 as well, so it might be worth checking what they are doing too. I think it might even be based on Spring Boot, or at least contain some of the same code, so there is a good chance that we can extract a common framework for building such apps.
This would certainly be a win-win for all, so long as it could be made flexible, much like how boot is already.
Is JCommander included with Spring Shell? We like JOpt in Spring Boot, and it seems pretty well suited to building a self-describing CLI, so maybe it's worth a look if you haven't tried it.
Actually, I have had quite a bit of experience in this space. I've used about 4-5 different CLI libraries in Java and JCommander is by far the most versatile, flexible and easy to use. I really like how it is annotation based (think @ConfigurationProperties
here), supports @file
syntax (think curl
), supports sub-commands (think git
), etc. I used to use JOpt a few years back but seemed to fall short for more complex use cases. That and it seemed more programmatic than it needed to be. I suggest taking a look at JCommander which was written by the same guy who wrote TestNG (@cbeust).
And to answer your question, no it is not bundled with Spring Shell. Btw, this SO question is kinda related to this topic http://stackoverflow.com/questions/25194410/what-is-the-recommended-way-to-add-first-class-command-line-processing-to-spring
from spring-shell.
Here's Grails shell (just for reference): https://github.com/grails/grails-core/tree/master/grails-shell
from spring-shell.
This article was helpful to me:
http://blog.comsysto.com/2014/12/22/spring-shell-an-easy-way-to-create-your-own-shell/
from spring-shell.
I have gotten this to work by hacking the BootStrap class a bit.
https://github.com/jeffellin/springshellwithboot
from spring-shell.
Closing as addressed for Shell 1 (see above). Spring Shell 2 plays nicely with Boot out of the box
from spring-shell.
Related Issues (20)
- backport(999): e2e native compile fail with jline 3.25.1
- Upgrade gradle 8.4
- EventLoop can attempt send without throwing
- backport(996): Script runner @ symbol breaks as option value
- Implement scenario lifecycle
- Using Terminal UI with normal commands
- Upgrade spring-boot 3.1.9
- Upgrade spring-boot 3.2.3
- Add opinionated logging integration
- Grid fixed item size goes to bottom right HOT 1
- @CommandScan does not include commands during testing HOT 1
- Non interactive test example fails because of duplicated help argument HOT 1
- Extend "script" command to accept classpath references HOT 2
- MultiItemSelector and SingleItemSelector run not prompting user and returning immediately on Windows 11 HOT 3
- Feature Request: Tell Spring Shell to ignore command line arguments HOT 1
- Initial ProgressView implementation HOT 1
- Script runner @ symbol breaks as option value
- ViewComponent should have more user friendly api
- Adding elasticsearch-rest-client makes spring-shell hang on exit HOT 3
- e2e native compile fail with jline 3.25.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-shell.