Skip to content

Commit d4ba908

Browse files
Merge pull request #704 from WadydX/fix/init-video-short-flag-conflict
fix(cli): resolve init --video short-flag collision with global -V
2 parents d27c4a1 + 2778845 commit d4ba908

3 files changed

Lines changed: 64 additions & 3 deletions

File tree

packages/cli/src/cli.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
// `hyperframes --version` near-instant (~10ms vs ~80ms).
66
import { VERSION } from "./version.js";
77

8-
if (process.argv.includes("--version") || process.argv.includes("-V")) {
8+
const argv = process.argv.slice(2);
9+
const commandArg = argv[0];
10+
const rootVersionRequested =
11+
commandArg === "--version" ||
12+
commandArg === "-V" ||
13+
(commandArg === undefined && (argv.includes("--version") || argv.includes("-V")));
14+
15+
if (rootVersionRequested) {
916
console.log(VERSION);
1017
process.exit(0);
1118
}
@@ -64,8 +71,8 @@ const main = defineCommand({
6471
// Telemetry — lazy-loaded, captured references for exit handlers
6572
// ---------------------------------------------------------------------------
6673

67-
const commandArg = process.argv[2];
68-
const command = commandArg && commandArg in subCommands ? commandArg : "unknown";
74+
const cliCommandArg = process.argv[2];
75+
const command = cliCommandArg && cliCommandArg in subCommands ? cliCommandArg : "unknown";
6976
const hasJsonFlag = process.argv.includes("--json");
7077

7178
// Captured references — populated when the lazy imports resolve.

packages/cli/src/commands/init.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,46 @@ describe("hyperframes init flag rename", () => {
132132
expect(injected).not.toContain("setTimeout");
133133
});
134134

135+
it("-v works as the short alias for --video", () => {
136+
const dir = mkdtempSync(join(tmpdir(), "hf-init-test-"));
137+
const target = join(dir, "proj");
138+
try {
139+
const res = runInit([
140+
target,
141+
"--example",
142+
"blank",
143+
"--non-interactive",
144+
"--skip-skills",
145+
"-v",
146+
"missing.mp4",
147+
]);
148+
expect(res.status).toBe(1);
149+
expect(res.stderr).toContain("Video file not found: missing.mp4");
150+
} finally {
151+
rmSync(dir, { recursive: true, force: true });
152+
}
153+
});
154+
155+
it("-V prints a migration error instead of version fast-path", () => {
156+
const dir = mkdtempSync(join(tmpdir(), "hf-init-test-"));
157+
const target = join(dir, "proj");
158+
try {
159+
const res = runInit([
160+
target,
161+
"--example",
162+
"blank",
163+
"--non-interactive",
164+
"--skip-skills",
165+
"-V",
166+
"missing.mp4",
167+
]);
168+
expect(res.status).toBe(1);
169+
expect(res.stderr).toContain("The -V short flag no longer maps to --video");
170+
} finally {
171+
rmSync(dir, { recursive: true, force: true });
172+
}
173+
});
174+
135175
it("--template prints a rename hint and exits non-zero", () => {
136176
const dir = mkdtempSync(join(tmpdir(), "hf-init-test-"));
137177
const target = join(dir, "proj");

packages/cli/src/commands/init.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,13 @@ export default defineCommand({
588588
video: {
589589
type: "string",
590590
description: "Path to a video file (MP4, WebM, MOV)",
591+
alias: "v",
592+
},
593+
"video-legacy": {
594+
type: "string",
595+
description: "[renamed] Use --video (or -v) instead of -V.",
591596
alias: "V",
597+
hidden: true,
592598
},
593599
audio: {
594600
type: "string",
@@ -638,6 +644,14 @@ export default defineCommand({
638644
);
639645
process.exit(1);
640646
}
647+
if (args["video-legacy"] !== undefined) {
648+
console.error(
649+
c.error(
650+
`The -V short flag no longer maps to --video. Use --video (or -v). Example:\n npx hyperframes init ${args.name ?? "my-video"} --video "${args["video-legacy"]}"`,
651+
),
652+
);
653+
process.exit(1);
654+
}
641655
const exampleFlag = args.example;
642656
const videoFlag = args.video;
643657
const audioFlag = args.audio;

0 commit comments

Comments
 (0)