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:
Miguel Ángel
2026-07-08 15:53:13 -04:00
committed by GitHub
parent f5f94a9495
commit e018318225
+9 -3
View File
@@ -238,9 +238,15 @@ export default defineCommand({
type: "string",
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",
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: {
type: "boolean",
@@ -250,7 +256,7 @@ export default defineCommand({
async run({ args }) {
const projectDir = resolve(args.dir ?? process.cwd());
const json = args.json === true;
const skipClipboard = args["no-clipboard"] === true;
const skipClipboard = args.clipboard === false;
const hasConfigBefore = existsSync(projectConfigPath(projectDir));
// Try single item first. If it fails, check if the name matches a tag.