feature: Adds better command line argument parsing.
This commit is contained in:
parent
ea2fd4bff1
commit
e85838d438
6 changed files with 663 additions and 37 deletions
24
lom/src/libs/patchCommander.ts
Normal file
24
lom/src/libs/patchCommander.ts
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue