diff --git a/bin/clocal-gcp b/bin/clocal-gcp deleted file mode 100755 index e5736df..0000000 --- a/bin/clocal-gcp +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -const program = require('commander'); - -const commandsArray = require('../src/services/index').commands; - -program.version('1.0.0').description('Clocal GCP'); - -const commandNameList = []; - -commandsArray.map(command => { - commandNameList.push(command.commandName); - program.command(command.commandName).action(command.action); -}); - -program.command('list').action(() => { - const commandNames = commandNameList.reduce((prev, current) => { - return `${prev}\n${current}`; - }, ''); - console.log(commandNameList.toString()); -}); - -program.parse(process.argv); diff --git a/bin/clocal-gcp.ts b/bin/clocal-gcp.ts new file mode 100755 index 0000000..99b98b1 --- /dev/null +++ b/bin/clocal-gcp.ts @@ -0,0 +1,32 @@ +const fs = require('fs'); +const program = require('commander'); +const main = process.cwd() + "/src/services/cli-commands/"; +let commandsArray = []; +const commandNameList = []; + +program.version('1.0.0').description('Clocal GCP'); + +fs.readdir(main, function(err, items) { + var totalImports = items.length + while (i >= totalImports) { + + const required = require('../src/services/cli-commands/'+items[i]+'/cmd'); + commandsArray = [required]; + + commandsArray.map(command => { + commandNameList.push(command.commandName); + program.command(command.commandName).action(command.action); + }); + i++; + } + + program.command('list').action(() => { + const commandNames = commandNameList.reduce((prev, current) => { + return `${prev}\n${current}`; + }, ''); + + console.log(commandNameList.toString()); + }); + + program.parse(process.argv); +});