Skip to content

stone-jin/tg-commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tg-commander logo

tg-commander NPM version NPM downloads

🎯 A laconic and Convenient tools for commander.

who use tg-commander?

Netease

Use

example:

git clone https://github.com/stone-jin/tg-commander-template.git
npm install
ts-node ./src/index.ts g name

# publish
npm run package
cd publish && npm publish

let's see the code.

import { Command, TgCommand, TgOptions } from "tg-commander";
import { HelloService } from "../service/hello";

@TgCommand
export class HelloCommand {

    @TgOptions("-p, --peppers [type]", "Add peppers")
    public type: string;

    @TgOptions("-t, --target [taget]", "Add peppers", "dev")
    public target: string;

    constructor(private helloService: HelloService) {

    }

    @Command("rmdir <cmd> [env]")
    public hello(cmd: any, env: any) {
        console.log(cmd, env);
        console.log(this.helloService.getName());
    }

    @Command({
        cmd: "g <module>",
        description: "create module",
    })
    public createModule(module: any) {
        console.log(this.type);
        console.log("you want to create module: " + module);
        console.log(this.target);
        console.log("====");
    }

    @Command({
        cmd: "new <product>",
        alias: "n",
        description: "new product",
    })
    public newProduct(product: string) {
        console.log(process.cwd());
        console.log("you want to create product: " + product);
    }
}
xxx g name

About

🐳 A laconic and Convenient tools for commander.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published