mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(cli): add help [cmd], suggest the closest command or flag, and quiet the nags (#6621)
* fix(cli): add help [cmd], suggest the closest command or flag, and quiet the nags
`hyperframes help` printed "Unknown command help" with raw ANSI codes and no
suggestion. It is now an alias: `help [cmd...]` is `[cmd...] --help`.
An unknown command (at the root or inside a group like `cloud`) prints
"Unknown command: rendr", "Did you mean 'hyperframes render'?" and the group's
usage, all on stderr, and exits 2. An unknown flag suggests the flag it most
likely means ("Did you mean --output?"). Usage text printed for a usage error
now goes to stderr instead of stdout, and citty's colors are stripped from
help whenever this CLI's own colors are off.
No update, skills or app-history notice is appended to a usage error. The
skills notice shows at most once a day per project (timestamps in
~/.hyperframes/skills-notice.json) and, in an unattended run, only when a core
skill is missing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(cli): reject an unknown top-level command without loading every command
citty looks for an alias on every registered command before it reports an
unknown name, which loads all of them. From a source checkout without the
studio packages built, that meant `hyperframes rendr` failed in preview's
build check with exit 1 instead of suggesting `render`. The name is now
checked against the registry first.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(cli): help with a mistyped subcommand reports it like the command itself
`hyperframes help cloud rendr` printed cloud's help and exited 0, while
`hyperframes cloud rendr` exits 2 with a suggestion. Both now exit 2 with the
suggestion. A group that also takes positional arguments (timeline takes a
project directory) still shows its help for a word it does not know.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3d1c0764a0
commit
e2c9151320
@@ -5,6 +5,8 @@ type LazyCommandDef = CommandDef | (() => CommandDef | Promise<CommandDef>);
|
||||
export interface ResolvedCommandUsage {
|
||||
command: CommandDef;
|
||||
parent?: CommandDef;
|
||||
path: string[];
|
||||
unknownSubcommand?: string;
|
||||
}
|
||||
|
||||
async function loadSubcommand(command: CommandDef, name: string): Promise<CommandDef | undefined> {
|
||||
@@ -21,12 +23,20 @@ export async function resolveCommandUsage(
|
||||
): Promise<ResolvedCommandUsage> {
|
||||
let command = root;
|
||||
let parent: CommandDef | undefined;
|
||||
const path: string[] = [];
|
||||
for (const argument of argv) {
|
||||
if (argument.startsWith("-")) break;
|
||||
const child = await loadSubcommand(command, argument);
|
||||
if (!child) break;
|
||||
if (!child)
|
||||
return {
|
||||
command,
|
||||
parent,
|
||||
path,
|
||||
unknownSubcommand: command.subCommands ? argument : undefined,
|
||||
};
|
||||
parent = command;
|
||||
command = child;
|
||||
path.push(argument);
|
||||
}
|
||||
return { command, parent };
|
||||
return { command, parent, path };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user