hunt-console 0.1.0
The Console component allows you to create command-line commands.
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:
Console Component
Console eases the creation of beautiful and testable command line interfaces.
It is a port from Symfony's Console component.
The Application object manages the command-line application:
import hunt.console;
console = new Application();
console.run(new ArgsInput(args));
The run()
method parses the arguments and options passed on the command
line and executes the right command.
Registering a new command can easily be done via the register()
method,
which returns a Command
instance:
void main(string[] args)
{
Application app = new Application("Hunt Console", "1.0.0");
app.setAutoExit(false);
app.add(new GreetingCommand());
app.add((new Command("test")).setExecutor(new class CommandExecutor {
override public int execute(Input input, Output output)
{
output.writeln("hello world");
return 0;
}
}));
if(args.length > 1)
app.run(args[1..$]);
else
app.run([]);
}
You can also register new commands via classes.
The component provides a lot of features like output coloring, input and output abstractions (so that you can easily unit-test your commands), validation, automatic help messages, ...
- Registered by zoujiaqing
- 0.1.0 released 5 years ago
- huntlabs/hunt-console
- www.huntlabs.net
- Apache-2.0
- Copyright (C) 2015-2018, HuntLabs
- Dependencies:
- hunt
- Versions:
-
0.4.0 2021-Oct-29 0.3.0 2021-Jan-27 0.2.0 2020-May-21 0.1.1 2020-Mar-19 0.1.0 2019-Jan-25 - Download Stats:
-
-
0 downloads today
-
1 downloads this week
-
6 downloads this month
-
1492 downloads total
-
- Score:
- 0.8
- Short URL:
- hunt-console.dub.pm