mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(cli): share projected flag binding lookup (#16333)
This commit is contained in:
1 parent
4caa302c80
commit
175fc298af
1 file changed
+4
-9
@@ -253,7 +253,7 @@ const cliConflictRemediation = (
|
||||
);
|
||||
if (!remediation.action.startsWith(mcp)) return undefined;
|
||||
const cliInputFields = inputFields.map((field) => {
|
||||
const flag = cliFlagForFlags(field, binding.flags);
|
||||
const flag = cliFlagFor(field, binding);
|
||||
if (flag !== undefined) return flag;
|
||||
return Object.hasOwn(binding.fields, field)
|
||||
? (binding.fields[field] ?? field)
|
||||
@@ -519,9 +519,9 @@ const limitParameter = (limit: JsonValue | undefined): string | undefined =>
|
||||
* parameter path names the flag: a flattened member option, else the option
|
||||
* of the whole field (such as `--producer-limits` JSON).
|
||||
*/
|
||||
const cliFlagForFlags = (
|
||||
const cliFlagFor = (
|
||||
parameter: string,
|
||||
flags: Readonly<Record<string, string>>,
|
||||
{ flags }: Pick<CliInputFieldBinding, "flags">,
|
||||
): string | undefined => {
|
||||
const segments = parameter.split(".");
|
||||
for (let length = segments.length; length > 0; length -= 1) {
|
||||
@@ -531,17 +531,12 @@ const cliFlagForFlags = (
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const cliFlagFor = (
|
||||
parameter: string,
|
||||
binding: Pick<CliInputFieldBinding, "flags">,
|
||||
): string | undefined => cliFlagForFlags(parameter, binding.flags);
|
||||
|
||||
const cliFlagForOperations = (
|
||||
parameter: string,
|
||||
operations: readonly CliCommandOperation[],
|
||||
): string | undefined => {
|
||||
for (const operation of operations) {
|
||||
const flag = cliFlagForFlags(parameter, operation.flags);
|
||||
const flag = cliFlagFor(parameter, operation);
|
||||
if (flag !== undefined) return flag;
|
||||
}
|
||||
return undefined;
|
||||
|
||||
Reference in new issue
Block a user