mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
* fix(cli): admit native data type selectors before opening a target * fix(cli): advertise the native data type selector choice * test(cli): reject invalid native data type selectors before target access * test(cli): cover native data type selector discovery * fix(cli): reject an empty native data type target before resolution inspect-native-data-type still declared its positional target as a plain string after #7956 moved its sibling local-file commands to localPathStringSchema, so an empty target passed validation and resolved to the working directory. Use the shared schema and cover the command in the empty-target admission table. * refactor(cli): share native data type selector guidance owner * test(cli): bind native data type selector checks to owning contracts
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
|
|
|
/** Each separately emitted args/options schema must expose the selector choice. */
|
|
export const requiredSelectorGuidance = (alternatives: string): string =>
|
|
`Supply at least one of ${alternatives}.`;
|
|
|
|
export const addressOrProcedureGuidance = requiredSelectorGuidance(
|
|
"the positional address or --procedure",
|
|
);
|
|
|
|
/** Agreement details belong on the command, rather than every schema field. */
|
|
export const equalSelectorGuidance =
|
|
"Equal values are accepted; conflicts fail.";
|
|
|
|
/** Data type selectors stay optional in the options schema; exactly one is required. */
|
|
export const dataTypeSelectorGuidance =
|
|
"Supply exactly one of --type or --address.";
|
|
|
|
/** Preserve a CLI selector supplied positionally or through its named option. */
|
|
export const resolveCliAnalysisSelector = (
|
|
positional: string | undefined,
|
|
named: string | undefined,
|
|
option: string,
|
|
operation: string,
|
|
): string => {
|
|
if (positional !== undefined && named !== undefined && positional !== named)
|
|
throw new AnalysisInputError(operation, undefined, [
|
|
{
|
|
path: [option],
|
|
reason: "invalid_value",
|
|
message: `The positional selector and --${option} select different objects; supply one selector.`,
|
|
},
|
|
]);
|
|
const selected = named ?? positional;
|
|
if (selected === undefined)
|
|
throw new AnalysisInputError(operation, undefined, [
|
|
{
|
|
path: [option],
|
|
reason: "missing_argument",
|
|
message: `Supply a positional selector or --${option}=<value>. Use the named option for values beginning with a dash.`,
|
|
expected: "string",
|
|
},
|
|
]);
|
|
return selected;
|
|
};
|