JavaScript port of famous Python click library for argument parsing
Install the package npm:
$ npm install python-clickjs --save
Alternatively if you are using yarn:
$ yarn add python-clickjs
TypeScript
Enable the compiler option experimentalDecorators
in tsconfig.json
or pass it as flag --experimentalDecorators
to the compiler.
Babel 7.x:
Install support for decorators: npm i --save-dev @babel/plugin-proposal-class-properties @babel/plugin-proposal-decorators
. And enable it in your .babelrc
file:
{
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true}],
["@babel/plugin-proposal-class-properties", { "loose": true}]
]
}
Babel 6.x:
Install support for decorators: npm i --save-dev babel-plugin-transform-decorators-legacy
. And enable it in your .babelrc
file:
{
"presets": ["es2015", "stage-1"],
"plugins": ["transform-decorators-legacy"]
}
Babel 5.x
{
"stage": 1
}
Probably you have more plugins and presets in your .babelrc
already, note that the order is important and transform-decorators-legacy
should come as first.
import Click from 'clickjs';
@Click.group()
class Command{
@Click.command("2")
@Click.argument("value")
@Click.argument("value2")
evaluate2(params){
console.log("command run 2()")
console.log(params);
}
@Click.command("1")
@Click.option("name")
@Click.option("name2", {default: '12'})
evaluate1(params){
console.log("command run 1()");
console.log(params);
}
}
@Command.group("3")
class SubCommand{
@Click.command("2")
evaluate2(params){
console.log("command run 3-2()");
console.log(