Skip to content
Open
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: 2 additions & 2 deletions src/lib/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export type OutputMode = 'json' | 'text';
/**
* Help-text footer pointing at the global options surface so users
* looking at any subcommand `--help` don't miss `--dry-run`, `--output`,
* `--profile`, `--endpoint-url`, `--debug`.
* `--profile`, `--endpoint-url`, `--request-timeout`, `--debug`.
*/
export const GLOBAL_OPTS_HINT =
'\nGlobal options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):' +
'\nGlobal options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):' +
'\n testsprite --help';

export function isOutputMode(value: unknown): value is OutputMode {
Expand Down
12 changes: 12 additions & 0 deletions src/lib/render-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ describe('rephraseUnknownOption', () => {
expect(result).toContain('--endpoint-url');
});

it('rephrases --request-timeout placed after subcommand', () => {
const result = rephraseUnknownOption("error: unknown option '--request-timeout'");
expect(result).not.toBeNull();
expect(result).toContain('--request-timeout');
});

it('rephrases --debug placed after subcommand', () => {
const result = rephraseUnknownOption("error: unknown option '--debug'");
expect(result).not.toBeNull();
Expand Down Expand Up @@ -87,6 +93,12 @@ describe('rephraseUnknownOption', () => {
expect(result).not.toBeNull();
expect(result).toContain('testsprite --endpoint-url <value> <subcommand>');
});

it('value flag (--request-timeout) example DOES include a <value> placeholder', () => {
const result = rephraseUnknownOption("error: unknown option '--request-timeout'");
expect(result).not.toBeNull();
expect(result).toContain('testsprite --request-timeout <value> <subcommand>');
});
});

describe('renderCommanderError', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/render-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import type { OutputMode } from './output.js';
*
* `boolean` flags (--dry-run, --debug, --verbose) take no value; emit
* example without a placeholder. `value` flags (--output, --profile,
* --endpoint-url) take a single argument; emit example with `<value>`.
* --endpoint-url, --request-timeout) take a single argument; emit example
* with `<value>`.
*/
const GLOBAL_FLAG_ARITY: Record<string, 'boolean' | 'value'> = {
'dry-run': 'boolean',
output: 'value',
profile: 'value',
'endpoint-url': 'value',
'request-timeout': 'value',
debug: 'boolean',
verbose: 'boolean',
};
Expand Down
30 changes: 15 additions & 15 deletions test/__snapshots__/help.snapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Options:
destroyed.
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -47,7 +47,7 @@ List supported agent targets, their status, and landing paths
Options:
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -84,7 +84,7 @@ exports[`--help snapshots > auth logout 1`] = `
Options:
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -95,7 +95,7 @@ exports[`--help snapshots > auth whoami 1`] = `
Options:
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -151,7 +151,7 @@ Get a project by id
Options:
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -173,7 +173,7 @@ Options:
--max-items <n> stop after this many items across auto-paged pages
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -278,7 +278,7 @@ Options:
source body; json mode: wire envelope)
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -313,7 +313,7 @@ Options:
per invocation; pin one yourself for safe retries.
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -329,7 +329,7 @@ Options:
--failed-only Keep only the failed step plus its immediate neighbors (±1)
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -342,7 +342,7 @@ Get a test by id
Options:
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -367,7 +367,7 @@ Options:
--max-items <n> stop after this many items across auto-paged pages
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -431,7 +431,7 @@ Dry-run shape notes:
omit \`closure\` (or return it as null) since there is no dependency expansion.
• \`autoHeal\` defaults true for FE reruns; BE reruns ignore the field entirely.

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -463,7 +463,7 @@ Options:
--cursor <token> with --history: opaque cursor from a prior page
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down Expand Up @@ -514,7 +514,7 @@ Dependency-aware fresh run (M4):
BE tests can declare --produces/--needs at create time to drive wave ordering
(see \`testsprite test create --help\` for details).

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand All @@ -537,7 +537,7 @@ Options:
excluded when this flag is set.
-h, --help display help for command

Global options (--dry-run, --output, --profile, --endpoint-url, --verbose, --debug):
Global options (--dry-run, --output, --profile, --endpoint-url, --request-timeout, --verbose, --debug):
testsprite --help
"
`;
Expand Down