jackwener/OpenCLI · error · ArgumentError
At least one of --json or --text must be enabled
Error message
At least one of --json or --text must be enabled
What it means
The transcript command saves a JSON file, a text file, or both; both flags default to true. If the user explicitly disables both (`--json false --text false`), there would be no output at all, so ArgumentError is thrown up front with an example invocation.
Source
Thrown at clis/xiaoyuzhou/transcript.js:24
cli({
site: 'xiaoyuzhou',
name: 'transcript',
access: 'read',
description: 'Download Xiaoyuzhou transcript as JSON and text (requires local credentials)',
domain: 'www.xiaoyuzhoufm.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'id', positional: true, required: true, help: 'Episode ID (eid from podcast-episodes output)' },
{ name: 'output', default: './xiaoyuzhou-transcripts', help: 'Output directory' },
{ name: 'json', type: 'boolean', default: true, help: 'Save transcript JSON file' },
{ name: 'text', type: 'boolean', default: true, help: 'Save extracted transcript text file' },
],
columns: ['title', 'podcast', 'status', 'segments', 'json_file', 'text_file'],
func: async (kwargs) => {
if (kwargs.json === false && kwargs.text === false) {
throw new ArgumentError('At least one of --json or --text must be enabled', 'Example: opencli xiaoyuzhou transcript 69dd0c98e2c8be31551f6a33 --text true');
}
let credentials = loadXiaoyuzhouCredentials();
const episodeResponse = await requestXiaoyuzhouJson('/v1/episode/get', {
query: { eid: kwargs.id },
credentials,
});
credentials = episodeResponse.credentials;
const episode = episodeResponse.data;
if (!episode) {
throw new CliError('NOT_FOUND', 'Episode not found', 'Please check the episode ID');
}
const mediaId = String(episode.transcript?.mediaId || episode.media?.id || episode.transcriptMediaId || '').trim();
if (!mediaId) {
throw new CliError('PARSE_ERROR', 'mediaId not found in episode payload', 'Transcript metadata requires episode.transcript.mediaId, episode.media.id, or episode.transcriptMediaId');
}
const transcriptResponse = await requestXiaoyuzhouJson('/v1/episode-transcript/get', {
method: 'POST',
body: {View on GitHub (pinned to 49907e53dc)
Solutions
- Enable at least one output: add `--text true` or `--json true`
- Remove the explicit `--json false`/`--text false` flags to use the defaults (both true)
- In wrapper scripts, guard that at least one output flag is enabled before invoking
Example fix
// before opencli xiaoyuzhou transcript <eid> --json false --text false // after opencli xiaoyuzhou transcript <eid> --text true
Defensive patterns
Strategy: validation
Validate before calling
if (opts.json === false && opts.text === false) throw new Error('Enable at least one of --json or --text'); Type guard
const hasOutput = (k) => k.json !== false || k.text !== false;
Try / catch
try { await transcript(id, {json, text}); } catch (e) { if (String(e).includes('--json or --text')) { console.error('Enable at least one output flag'); process.exitCode = 2; } else throw e; } Prevention
- Never pass --json false and --text false together
- Keep default flags (both true) unless you need to suppress output
- In config-driven wrappers, assert at least one output is on
- Test automation flag assembly for boolean coercion
When it happens
Trigger: Running `opencli xiaoyuzhou transcript <eid> --json false --text false`, or a wrapper script that builds flags from config where both output options are disabled.
Common situations: Config templates with `output.json=false` and `output.text=false`, misunderstanding that 'false' for one flag means 'the other still works', or automations passing boolean flags as strings that coerce oddly.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- --period is only valid with --view top
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fa35c050bd0f52d6.
Report an issue: GitHub.