mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
refactor: consolidate shared analysis boundaries (#10293)
This commit is contained in:
1 parent
6878a84796
commit
c836f57b7d
70 files changed
+1240
-1131
No files matched your search
@@ -0,0 +1,21 @@
|
||||
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", message },
|
||||
]),
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user