diff --git a/src/index.ts b/src/index.ts index 6bc2d5d..0bb6887 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,19 @@ #!/usr/bin/env node const program = require('commander'); +import * as Stock from './stock'; program .version('0.0.1') .description("Stock CLI for getting stock information") .arguments('get [otherStocks...]', 'get one or more stocks price') - .action((cmd: string, stocks?: string[]) => { - console.log("Instruction: %s", cmd); - if (stocks){ - console.log("And other stocks: %s", stocks.join("-")); + .action((cmd: string, stocks: string[] = []) => { + switch(cmd) { + case "get": + Stock.get(stocks); + break; + default: + console.log(`No "${cmd}" method.`) } }); diff --git a/src/stock.ts b/src/stock.ts new file mode 100644 index 0000000..6afeb3d --- /dev/null +++ b/src/stock.ts @@ -0,0 +1,9 @@ + +const get = (args: string[]): void => { + console.log(`You want to fetch ${args}`); + return; +} + +export { + get +}