simple-task-master
Version:
A simple command-line task management tool
79 lines • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const package_json_1 = require("../package.json");
const errors_1 = require("./lib/errors");
// Import commands
const init_1 = require("./commands/init");
const add_1 = require("./commands/add");
const delete_1 = require("./commands/delete");
const list_1 = require("./commands/list");
const show_1 = require("./commands/show");
const update_1 = require("./commands/update");
const grep_1 = require("./commands/grep");
const export_1 = require("./commands/export");
const config_1 = require("./commands/config");
// Set up process error handlers only if not in test environment
if (process.env.NODE_ENV !== 'test') {
process.on('unhandledRejection', (reason) => {
(0, errors_1.handleGlobalError)(new Error(`Unhandled rejection: ${String(reason)}`));
});
process.on('uncaughtException', (error) => {
// Handle EPIPE errors specifically - they occur when writing to a closed pipe
if (error.code === 'EPIPE') {
// EPIPE errors are usually not fatal and can be ignored
// They commonly occur when the stdin/stdout pipe is closed prematurely
// Log a warning but don't crash the process
console.warn('Warning: Broken pipe detected (EPIPE). This is usually not an error.');
return;
}
(0, errors_1.handleGlobalError)(error);
});
// Handle EPIPE errors on stdout/stderr streams
process.stdout.on('error', (error) => {
if (error.code === 'EPIPE') {
// EPIPE on stdout is common when output is piped to a command that exits early
// (e.g., `stm list | head -1`). This is expected behavior.
process.exit(0);
}
});
process.stderr.on('error', (error) => {
if (error.code === 'EPIPE') {
// EPIPE on stderr is also common in similar scenarios
process.exit(0);
}
});
}
// Create the main program
const program = new commander_1.Command();
program
.name('stm')
.description(package_json_1.description)
.version(package_json_1.version, '-v, --version', 'display version information')
.configureHelp({
sortSubcommands: true,
sortOptions: true
});
// Register commands
program.addCommand(init_1.initCommand);
program.addCommand(add_1.addCommand);
program.addCommand(delete_1.deleteCommand);
program.addCommand(list_1.listCommand);
program.addCommand(show_1.showCommand);
program.addCommand(update_1.updateCommand);
program.addCommand(grep_1.grepCommand);
program.addCommand(export_1.exportCommand);
program.addCommand(config_1.configCommand);
// Parse command line arguments
async function main() {
try {
await program.parseAsync(process.argv);
}
catch (error) {
(0, errors_1.handleGlobalError)(error);
}
}
// Run the CLI
void main();
//# sourceMappingURL=cli.js.map