Giter Club home page Giter Club logo

extendedcli's Introduction

ExtendedCLI

Build Status codecov BCH compliance Known Vulnerabilities

ExtendedCLI is a Command Line Interface framework that allows its users to build complex fully-customizable CLIs in Java. Through ExtendedCLI users are able:

  • Design a CLI with multiple commands, each command with a set of customizable options;
  • Each command follows the command pattern, providing an execute() and undo() methods;
  • Each option follows the classic format -option_name, and can be assigned with a value (in the form of -option_name value), a default value and a description;
  • For the most advanced and creative users, the CLI can be assigned with a custom input and output stream, allowing users to use the CLI from custom environments (from system consoles to files or even messaging applications such as Slack or Telegram)

Getting Started

ExtendedCLI uses maven as a package manager, but it not yet available in the maven repository. However, while the first official version of ExtendedCLI is not released, you can download the stable version through jitpack (available for Maven, Graddle, sbt and leiningen).

After including ExtendedCLI in your project, you're ready to build your first Command Line Interface!

Basic Usage

The whole framework works around the ExtendedCLI class. An ExtendedCLI instance works as regular CLI object: it stores all your custom commands and receives pieces of input (i.e. lines), which it processes. ExtendedCLI instances are built through CLIBuilder as such:

boolean ignoreCase = true;
CLIBuilder builder = new CLIBuilder(ignoreCase);
builder.registerCommand("command1", new Command1());
builder.registerCommand("command2", new Command2());
// ... register all commands
ExtendedCLI cli = builder.build();

The newly created ExtendedCLI instance stores all the registered commands, and is ready to start processing lines of input:

String line = "command1 -p path_to_something";
try {
  cli.execute(line);
} catch (NoSuchCommandException e) {
  System.out.println("Unkown Command.");
}

When executed, the line "command1 -p path_to_something" is processed by the ExtendedCLI instance:

  • The first word is matched to the registered command according to the name it was registered to (i.e. "command1" is matched to the Command1 instance created above).
  • The matched command is executed with all the data extracted from the input line.

extendedcli's People

Contributors

jpdsousa avatar tunedmidja avatar annawinkler avatar kirksc1 avatar jasper-vandemalle avatar

Watchers

Chris avatar

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.