sourcecontrol
Version:
A modern TypeScript CLI application for source control
96 lines • 3.6 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const utils_1 = require("./utils");
const commands_1 = require("./commands");
const cli_1 = require("./utils/cli");
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
const program = new commander_1.Command();
program
.name('sourcecontrol')
.description('🎯 A modern, beautiful source control CLI application')
.version(pkg.version, '-v, --version', '📋 Display version information')
.option('-V, --verbose', '🔍 Enable verbose logging')
.option('-q, --quiet', '🔇 Suppress output')
.option('--config <path>', '⚙️ Specify config file path')
.configureHelp({
formatHelp: (cmd) => (0, cli_1.formatHelp)(cmd),
})
.hook('preAction', (thisCommand) => {
const options = thisCommand.opts();
if (options['quiet']) {
utils_1.logger.level = 'silent';
}
else if (options['verbose']) {
utils_1.logger.level = 'debug';
}
});
program.addCommand(commands_1.hashObjectCommand);
program.addCommand(commands_1.catFileCommand);
program.addCommand(commands_1.initCommand);
program.addCommand(commands_1.destroyCommand);
program.addCommand(commands_1.lsTreeCommand);
program.addCommand(commands_1.writeTreeCommand);
program.addCommand(commands_1.checkoutTreeCommand);
program.addCommand(commands_1.ignoreCommand);
program.addCommand(commands_1.configCommand);
program.addCommand(commands_1.addCommand);
program.addCommand(commands_1.statusCommand);
program.addCommand(commands_1.commitCommand);
program.addCommand(commands_1.createSampleCommand);
program.exitOverride();
try {
program.parse();
}
catch (err) {
if (err.code === 'commander.version') {
(0, cli_1.displayVersion)();
process.exit(0);
}
if (err.code === 'commander.help') {
process.exit(0);
}
(0, cli_1.displayError)(err);
process.exit(1);
}
if (!process.argv.slice(2).length) {
(0, cli_1.displayWelcome)();
console.log('\n' + (0, cli_1.formatHelp)(program));
}
//# sourceMappingURL=cli.js.map
;