mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
fix(speech): validate --words JSON before auth
Invalid vocabulary JSON was parsed in run(), so CI without an API key failed with AUTH(3) instead of USAGE(2).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
readTextFromPathOrStdin,
|
||||
parseVocabularyEntries,
|
||||
UsageError,
|
||||
type FlagsDef,
|
||||
type ParsedFlags,
|
||||
type VocabularyEntry,
|
||||
@@ -61,6 +62,17 @@ export function validateVocabularySource(flags: VocabularySourceFlags): string |
|
||||
if (flags.words && flags.wordsFile) {
|
||||
return "Use either --words or --words-file, not both.";
|
||||
}
|
||||
if (!flags.words) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
parseVocabularyEntries(flags.words, flags.lang);
|
||||
} catch (error) {
|
||||
if (error instanceof UsageError) {
|
||||
return error.message;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user