feature: Adds better command line argument parsing.

This commit is contained in:
greysoh 2024-05-06 20:21:10 -04:00
parent ea2fd4bff1
commit e85838d438
No known key found for this signature in database
GPG key ID: FE0F173B8FC01571
6 changed files with 663 additions and 37 deletions

View file

@ -0,0 +1,24 @@
// @ts-nocheck
import type { Command } from "commander";
import { PrintLine } from "../commands";
export type AppState = {
hasRecievedExitSignal: boolean
}
export function patchCommander(program: Command, appState: AppState, println: PrintLine) {
program.exitOverride(() => {
appState.hasRecievedExitSignal = true;
});
program._outputConfiguration.writeOut = (str) => println(str);
program._outputConfiguration.writeErr = (str) => {
if (str.includes("--help")) return;
println(str);
};
program._exit = (exitCode, code, message) => {
appState.hasRecievedExitSignal = true;
}
}