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
4 changes: 3 additions & 1 deletion src/commands/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ const typeSub = defineCommand({
args: {
...commonArgs,
id: idArg,
text: { type: 'string', description: 'What to type', required: true },
// Not `required`: citty would reject a missing value before runDeviceCommand,
// and --json would then print the top-level error instead of the envelope.
text: { type: 'string', description: 'What to type' },
sensitive: {
type: 'boolean',
default: false,
Expand Down
10 changes: 10 additions & 0 deletions test/unit/device-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ describe('dcd device', () => {
expect(calls[1].body).to.deep.equal({ type: 'type', text: 'hello' });
});

it('type without --text is a usage error inside the envelope, not a citty error', async () => {
const calls = stubFetch(ok);
const { exit, out } = await runJson('type', { id: 'a-b-c' });
expect(exit).to.equal(DEVICE_EXIT.usage);
expect(out).to.have.keys('ok', 'session', 'data', 'error');
expect(out.ok).to.equal(false);
expect((out.error as { message: string }).message).to.include('--text');
expect(calls).to.have.length(0);
});

it('swipe takes a direction as its only positional, or --from and --to', async () => {
const calls = stubFetch((call) =>
call.url.endsWith('/device/sessions') ? { body: { sessions: [session('a-b-c')] } } : ok(),
Expand Down
Loading