Files
reverse-engineering-anything/src/cli/cliJsonOption.ts
T
morluto 104b1a35b4 fix(contracts): refuse empty address and procedure selectors in the contracts (#10753)
* 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
2026-11-15 22:03:37 +08:00

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 },
]),
);
};