Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ typings/
# dotenv environment variables file
.env

# Mac Junk
.DS_Store

43 changes: 25 additions & 18 deletions bin/clocal-gcp
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@

'use strict';

const program = require('commander');

const commandsArray = require('../src/services/index').commands;
let commandsArray = [];
const commandNameList = [];
const fs = require('fs');
const program = require('commander');
const main = process.cwd() + "/src/services/cli-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);
fs.readdir(main, function(err, total) {
for (var i=0; i<total.length; i++) {
const required = require('../src/services/cli-commands/'+total[i]+'/cmd');
commandsArray = [required];
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);

});
Loading