Code Monkey home page Code Monkey logo

Comments (11)

linux-china avatar linux-china commented on May 22, 2024 4

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.

kpb avatar kpb commented on May 22, 2024 2

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.

btiernay avatar btiernay commented on May 22, 2024

Agreed. Im looking to do the same for the same reasons.

from spring-shell.

dsyer avatar dsyer commented on May 22, 2024

What is it that is "nice" about Spring Shell that you can't do with Spring Boot (especially with the CLI)?

from spring-shell.

btiernay avatar btiernay commented on May 22, 2024

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.

dsyer avatar dsyer commented on May 22, 2024

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.

btiernay avatar btiernay commented on May 22, 2024

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.

dima767 avatar dima767 commented on May 22, 2024

Here's Grails shell (just for reference): https://github.com/grails/grails-core/tree/master/grails-shell

from spring-shell.

hansvanbeneden avatar hansvanbeneden commented on May 22, 2024

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.

jeffellin avatar jeffellin commented on May 22, 2024

I have gotten this to work by hacking the BootStrap class a bit.

https://github.com/jeffellin/springshellwithboot

from spring-shell.

ericbottard avatar ericbottard commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.