Git Product home page Git Product logo

je2sh's Introduction

This is JeeSh

Build Status CodeFactor

JeeSh stands for "JVM Extensible & Embeddable Shell". It aims at being a reboot of the famous Common Reusable SHell (CRaSH).

Motivation

CRaSH is no longer maintained and Spring Boot is removing support for it with release 2.0. Having the ability to access Spring features through SSH is very handy, especially for administrative tasks.

We envisioned three common use-cases:

  • Standalone shell. Useful for encoding utilities
  • SSH Server. If you want to have JeeSh running on your server providing functionality not available on a normal *nix shell or for embedding it into a Spring application (common use case for CRaSH)
  • REST Endpoints. Allows you to expose your commands through a REST API, making it easy to create both a healthy repertoire of features and a client layer (other than SSH) to interact with it. The examples project provides a sample on how to use JQueryTerminal for this purpose.

First Steps

You can check JeeSh in action right after checking out the project. The examples module is a Spring Boot app that bootstraps JeeSh as both a SSH server and a REST API endpoint. Just run ./gradlew :examples:bootRun and navigate to http://localhost:8080/ or run ssh -p 2003 admin@localhost (admin:admin).

Try the help command.

First Command

JeeSh just takes advantage of JCommander for command specification. Here is the entire code of the built in hello command

@Parameters(commandNames = {"hello", "hi"} , commandDescription = "Just says hello")
public class Hello extends AbstractCommand {

    @Parameter(names = {"-n", "--name"}, description = "Your name")
    private String name;

    @Override
    public void execute(@NotNull CommandContext context) {
        context.println("Hello " + Optional.ofNullable(name).orElse("World"));
    }

}

The requirements:

  • Annotate your command with @Parameters
  • Implement Command. You will typically extend net.je2sh.core.AbstractCommand for convenience.

Architecture

JeeSh is broken down into multiple modules, allowing users to only import what they need. By design, and for experimentation purposes, it is built using Java 8 and Kotlin.

The base idea is that you can just define your commands using JCommander and those will be automatically picked up by JeeSh (if annotations module is used).

For parsing and rendering we use jline3, which allows using ANSI encodings and overall makes life easier.

Core

The core module provides the basis for everything else. Necessary interfaces and glue to interconnect the different components that build JeeSh.

Annotations

Enables the magic of interpreting @Parameters.

This module provides an annotation processor that creates a CommandProvider for you and makes it available as a ServiceProvider (META-INF/services) which is how core loads the available commands.

Mode on this subject later on.

Base Plugins

Small set of builtin plugins. Function mostly as an reference but also includes the help command.

Shell

Standalone shell instant that can be executed from the terminal

SSH

Pretty much self-explanatory.

Spring (Boot)

When included this module autoconfigures JeeSh according the the properties you define. By default both a SSH Server and a REST API will be enabled. These however can be controlled through the properties: jeesh.ssh.enabled and jeesh.rest.enabled respectively (to be added on your application.[properties|yaml]).

Disclaimer

This is definitely a work in progress so there is definitely a lot of room for improvement. If you want to contribute go ahead and grab an issued or submitted your awesome new feature!

Licensed under the MIT License (LICENSE)

je2sh's People

Contributors

hartimer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hartimer xerocry

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.