mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(cli): add --no-clipboard no longer throws "Unknown flag: --clipboard" (#2067)
The add command declared its flag literally as `"no-clipboard"`, but citty treats `--no-<name>` as the negation of a boolean `<name>` arg. So `--no-clipboard` parsed as negating a (nonexistent) `clipboard` arg and assertKnownFlags threw "Unknown flag: --clipboard" — even though --help advertised --no-clipboard as valid. Declare the positive `clipboard` (boolean, default true) instead and read `args.clipboard === false`; citty's built-in negation then handles `--no-clipboard` correctly. --help still lists both spellings. Verified: `hyperframes add data-chart --no-clipboard` now succeeds instead of erroring on the flag.
This commit is contained in:
@@ -238,9 +238,15 @@ export default defineCommand({
|
|||||||
type: "string",
|
type: "string",
|
||||||
description: "Project directory (defaults to the current working directory)",
|
description: "Project directory (defaults to the current working directory)",
|
||||||
},
|
},
|
||||||
"no-clipboard": {
|
clipboard: {
|
||||||
|
// Declared as the positive `clipboard` (default on) so citty's built-in
|
||||||
|
// `--no-<name>` negation handles `--no-clipboard`. Declaring the arg
|
||||||
|
// literally as `"no-clipboard"` made citty parse `--no-clipboard` as the
|
||||||
|
// negation of a (nonexistent) `clipboard` arg, so assertKnownFlags threw
|
||||||
|
// "Unknown flag: --clipboard" even though --help advertised it.
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
description: "Skip copying the include snippet to the clipboard",
|
default: true,
|
||||||
|
description: "Copy the include snippet to the clipboard (use --no-clipboard to skip)",
|
||||||
},
|
},
|
||||||
json: {
|
json: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
@@ -250,7 +256,7 @@ export default defineCommand({
|
|||||||
async run({ args }) {
|
async run({ args }) {
|
||||||
const projectDir = resolve(args.dir ?? process.cwd());
|
const projectDir = resolve(args.dir ?? process.cwd());
|
||||||
const json = args.json === true;
|
const json = args.json === true;
|
||||||
const skipClipboard = args["no-clipboard"] === true;
|
const skipClipboard = args.clipboard === false;
|
||||||
const hasConfigBefore = existsSync(projectConfigPath(projectDir));
|
const hasConfigBefore = existsSync(projectConfigPath(projectDir));
|
||||||
|
|
||||||
// Try single item first. If it fails, check if the name matches a tag.
|
// Try single item first. If it fails, check if the name matches a tag.
|
||||||
|
|||||||
Reference in New Issue
Block a user