bs-commander
v0.0.2
Published
BuckleScript bindings for tj/commander.js
Downloads
1
Maintainers
Readme
bs-commander
BuckleScript bindings for tj/commander.js.
Status
This package is a 🚧 WIP 🚧 project. Some methods may not work properly to fit all of your cases, so best to do is to check the implementation of the bindings.
Variations from original package
Declaring program variable
I decided to force usage of commander.Command()
for clarity reasons. So in order to have a program
variable, you must use the following:
let program = CommanderRe.newCommand();
Using version
Since the version
method has several signatures, you must be specific about your usage:
program->version("0.0.1");
program->versionWithFlags("0.0.1", "-v, --vers", "output the current version");
Using outputHelp
Same thing as above. Be specific.
program->outputHelp();
program->outputHelp(help => help->String.uppercase);
Using option
program
->option("-d, --debug", "output extra debugging")
->option("-s, --small", "small pizza size")
->option("-p, --pizza-type <type>", "flavour of pizza");
program
->optionWithDefault("-c, --cheese", "add the specified type of cheese", "blue");
program
->optionWithProcessing("-c, --cheese", "add the specified type of cheese", value => value->String.uppercase);
program
->optionWithProcessingAndDefault("-c, --cheese", "add the specified type of cheese", (value, _previous) => value->String.uppercase, "blue");
Example
open CommanderRe;
let program = newCommand();
program->version("1.0.0");
program
->option("-d, --debug", "output extra debugging")
->option("-s, --small", "small pizza size")
->option("-p, --pizza-type <type>", "flavour of pizza");
program->parse(argv);
switch (program->getOption("debug")) {
| None => ()
| Some(_) => Js.log("Debug")
};
switch (program->getOption("small")) {
| None => ()
| Some(_) => Js.log("- small pizza size")
};
switch (program->getOption("pizzaType")) {
| None => ()
| Some(pizzaType) => Js.log("- " ++ pizzaType)
};