Spring Shell

The Spring Shell project provides an interactive shell that allows you to plugin your own custom commands using a Spring based programming model.

Quick Start
Fork me on GitHub


Users of the Spring Shell project can easily build a full featured shell ( aka command line) application by depending on the Spring Shell jar and adding their own commands (which come as methods on spring beans). Creating a command line application can be useful e.g. to interact with your project's REST API, or to work with local file content.


Spring Shell's features include

  • A simple, annotation driven, programming model to contribute custom commands
  • Use of Spring's classpath scanning functionality as the basis for a command plugin strategy and command development
  • Tab completion, colorization, and script execution
  • Customization of command prompt, banner, shell history file name
  • Dynamic enablement of commands based on domain specific criteria
  • Already built-in commands, such as clear screen, help, exit, etc.

Quick Start


The recommended way to get started using spring-shell in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.

Then to create a simple command that could be invoked as

shell:>translate "hello world!" --from en_US --to fr_FR
bonjour monde!

assuming you'd have access to some kind of translation service that worked with Locales:

package foo;

import foo;

public class TranslationCommands {

    private final TranslationService service;

    public TranslationCommands(TranslationService service) {
      this.service = service;

    @CliCommand(value = "translate", help = "translate text from one language to another")
    public String translate(@CliOption(key = {"", "text"}) String text,
      @CliOption(key = "from", unspecifiedDefaultValue = "en_US") Locale from,
      @CliOption(key = "to") Locate to
    ) {
      // Check args, etc.

      // invoke service
      return service.translate(text, from, to);