Annotations to quickly create Command line utilities with commanderjs and typescript
npm install commanderjsdecoratorstypescript
import { command, action } from "commanderjsdecorators";
import commander from "commander";
@command({
commander: commander,
title: "XYZ",
description: "saying hello",
options: [
{ title: "-h, --hello [name]", description: "say hello" },
{ title: "-z, --sleep", description: "going to sleep" }
]
})
export class hello {
@action()
action(cmd: string, options: commander.Command) {
console.log("launching hello");
if(options.hello){
console.log("hello: " + options.hello);
}
if(options.sleep){
console.log("sleep: " + options.sleep);
}
}
}
`
Import the class for side effects only in you main file
`typescript
import "./hello";
//rest of your application
``