mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 02:40:43 +00:00
fix(cli): fast-path bare channels help (#77659)
* fix(cli): fast-path bare channels help * fix(cli): normalize channels add argv gating * fix(cli): restore channel add completion flags
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
import type { Command } from "commander";
|
||||
|
||||
const parentDefaultHelpCommands = new WeakSet<Command>();
|
||||
|
||||
function outputParentHelpWithoutStartupBanner(parent: Command): void {
|
||||
const previous = process.env.OPENCLAW_SUPPRESS_HELP_BANNER;
|
||||
process.env.OPENCLAW_SUPPRESS_HELP_BANNER = "1";
|
||||
try {
|
||||
parent.outputHelp();
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.OPENCLAW_SUPPRESS_HELP_BANNER;
|
||||
} else {
|
||||
process.env.OPENCLAW_SUPPRESS_HELP_BANNER = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire a parent command so that invoking it without a subcommand prints the
|
||||
* parent's own help and exits with status `0`.
|
||||
@@ -15,8 +31,13 @@ import type { Command } from "commander";
|
||||
* callers keep that ownership explicit instead of probing private internals.
|
||||
*/
|
||||
export function applyParentDefaultHelpAction(parent: Command): void {
|
||||
parentDefaultHelpCommands.add(parent);
|
||||
parent.action(() => {
|
||||
parent.outputHelp();
|
||||
outputParentHelpWithoutStartupBanner(parent);
|
||||
process.exitCode = 0;
|
||||
});
|
||||
}
|
||||
|
||||
export function isParentDefaultHelpAction(parent: Command): boolean {
|
||||
return parentDefaultHelpCommands.has(parent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user