command 0.0.7

A lightweight framework for designing interactive CLI applications


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:


This package provides sub packages which can be used individually:

command:lib - A lightweight framework for designing interactive CLI applications

command:grammar - Generator for the command grammar

command:varstore - A minimal D application.

command:greeter - A minimal D application.

command

This is a simple command-line framework that I devised while writing a "very secret" project for an internship.

Status

This library is still in-dev.

PLEASE NOTE: By default, the library will *NOT* spawn a new thread and read from stdin. This functionality is *opt-in*, and you MUST compile the library with the `cli` version for this. This is done via:

// dub.sdl
subConfiguration "command" "cli"
// dub.json
"subConfigurations": {
    "command": "cli"
}
    

ADDITIONAL NOTE: Compiling the library with the `cli` will bring in `linenoise` as a dependency.

Design Goals:

  • Lightweight
    • Minimal dependencies (only 2, but 1 is optional)
  • Portable
  • Easy to use

Examples

class TestExample {
@CommandNamespace("test"):
    // name, description, min args, max args
    @Command("hello", "Hello, World!", 0, 0)
    string hello(string[] args) {
        return "Hello, World!";
    }

    @Command("user", "Say hello to someone!", 1, 1)
    string hello_user(string[] args) {
        return "Hello, " ~ args[0] ~ "!";
    }
}

mixin RegisterModule!TestExample;

then, in the CLI:

> test.hello
Hello, World!
> test.hello()
Hello, World!
> test.user("Foo")
Hello, Foo!

TODO:

  • Proper return types
    • Avoid using strings as a type everywhere
  • Small standard library for ease of use
    • No user-defined functions however
      • By design, we're not trying to be a scripting engine
  • Well-defined instantiation order
    • In the end, this won't matter (since you can't call until the engine has been fully initialized), but might be worth investigating
Authors:
  • Harrison Ford
Sub packages:
command:lib, command:grammar, command:varstore, command:greeter
Dependencies:
command:lib
Versions:
0.0.8 2020-Nov-23
0.0.7 2020-Nov-07
0.0.6 2020-Nov-07
0.0.5 2020-Nov-07
0.0.4 2020-Nov-07
Show all 9 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 28 downloads total

Score:
0.6
Short URL:
command.dub.pm