Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/packages/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ Measure how sound moves in time, so a cut or an animation can land on it.

```bash
npx hyperframes audio sfx/whoosh.mp3 # one file, in file seconds
npx hyperframes audio sfx/hit.wav sfx/whoosh.mp3 # several files, one report
npx hyperframes audio sfx/hit.wav --place-at 4.2 # not in the film yet: where it lands if it starts at 4.2 s
npx hyperframes audio --element '#riser' # one clip of the film, in film seconds
npx hyperframes audio --at 12 # every sound playing at 12 s
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/cli.commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function commandLoaderBlock(): string {

// Vite cannot resolve a template-string import, so each listed top-level command is named here.
const LIST_COMMANDS: Record<string, () => Promise<{ default: unknown }>> = {
audio: () => import("./commands/audio.js"),
catalog: () => import("./commands/catalog.js"),
compare: () => import("./commands/compare.js"),
figma: () => import("./commands/figma.js"),
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/src/utils/reject-extra-positionals.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type { ArgsDef, CommandDef } from "citty";
import audio from "../commands/audio.js";
import { CliUsageError } from "./commandResult.js";
import { resolveExtraPositionals } from "./reject-extra-positionals.js";

afterEach(() => vi.restoreAllMocks());

describe("resolveExtraPositionals", () => {
it("lets audio take several files, which its help promises and its analysis handles", () => {
const parsed = { _: ["a.wav", "b.wav"], files: "a.wav" };
expect(() =>
resolveExtraPositionals(audio as CommandDef<ArgsDef>, "audio", parsed),
).not.toThrow();
});

it("still rejects an extra argument for a command that reads one", () => {
vi.spyOn(console, "error").mockImplementation(() => {});
const single = { args: { file: { type: "positional" } } } as CommandDef<ArgsDef>;
expect(() => resolveExtraPositionals(single, "single", { _: ["a", "b"], file: "a" })).toThrow(
CliUsageError,
);
});
});
1 change: 1 addition & 0 deletions packages/cli/src/utils/reject-extra-positionals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isTextFile } from "./textFile.js";

// Leaf commands that read extra positionals from `args._` on purpose, by command path.
export const ACCEPTS_EXTRA_POSITIONALS = new Set([
"audio",
"compare",
"figma asset",
"skills update",
Expand Down
Loading