mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
* fix(contracts): refuse empty address and procedure selectors in the contracts * refactor(cli): project decompile from its contract with --file-offset as an alternative selector (#10756) * refactor(cli): project search from its contracts with --kind choosing the operation (#10761) * refactor(cli): project search from its contracts with --kind choosing the operation * fix(cli): check operation choices' option rules and bind errors to the selected contract * test(cli): group operation-choice checks in their own block * refactor(cli): project decompile-all from its contract onto a native session target (#10778) * refactor(cli): project decompile-all from its contract onto a native session target * refactor(cli): project native Mach-O, Swift and native UI commands from their contracts * fix(cli): read search, decompile-all and native utility contracts from their groups so startup stays lazy * test(cli): drop the empty-selector admission mismatches the contracts now refuse
22 lines
721 B
TypeScript
22 lines
721 B
TypeScript
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
import { err, ok, type Result } from "../domain/result.js";
|
|
import { safeParseJson } from "../domain/safeJson.js";
|
|
|
|
/** Decode one named CLI option before using the selected inputs. */
|
|
export const parseCliJsonOption = (
|
|
operation: string,
|
|
name: string,
|
|
text: string | undefined,
|
|
message: string,
|
|
): Result<unknown, AnalysisInputError> => {
|
|
if (text === undefined) return ok(undefined);
|
|
const parsed = safeParseJson(text);
|
|
return parsed.ok
|
|
? parsed
|
|
: err(
|
|
new AnalysisInputError(operation, { cause: parsed.cause }, [
|
|
{ path: [name], reason: "invalid_format", expected: "JSON", message },
|
|
]),
|
|
);
|
|
};
|