redux-feature-generator
Version:
Generate Redux feature code from the command line
41 lines (40 loc) • 1.54 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @file cli.ts
* @version 1.4.0
* @fileoverview Main file for handling the commands
*/
const rfg_1 = require("./lib/rfg");
const rfgArgs_1 = require("./lib/rfgArgs");
// Read Arguments from the user
const rfgCommandObj = rfgArgs_1.rfgApi.processCommand(process.argv.splice(process.execArgv.length + 2));
// Handle the status of the read attempt
switch (rfgCommandObj.status) {
case rfgArgs_1.RFG_STATUS.HELP:
console.log(rfgArgs_1.rfgApi.getHelp());
process.exit(0);
case rfgArgs_1.RFG_STATUS.VERSION:
console.log(rfgArgs_1.rfgApi.getVersion(require("../../package.json")));
process.exit(0);
case rfgArgs_1.RFG_STATUS.ERROR:
console.log(`\n${rfgArgs_1.rfgApi.getHelp()}\n\n`);
process.exit(2);
case rfgArgs_1.RFG_STATUS.OK:
const cmdStatus = (0, rfg_1.generateFiles)((rfgCommandObj.argv));
switch (cmdStatus) {
case rfgArgs_1.RFG_STATUS.OK:
console.log(`Exit Status ${cmdStatus}\n\n`);
break;
case rfgArgs_1.RFG_STATUS.ERROR:
console.log(`Exit Status ${cmdStatus}\n\n`);
break;
case rfgArgs_1.RFG_STATUS.FOLDER_NOT_FOUND_ERROR:
console.log(`Exit Status ${cmdStatus}\nCould not find target folder for generation\n\n`);
break;
}
process.exit(cmdStatus);
default:
process.exit(rfgCommandObj.status);
}
;