cli: fix editor remove call validation
Skip type validation, fix passing values to remove Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
215f7a2ec5
commit
bd073e5cd9
1 changed files with 11 additions and 0 deletions
|
@ -136,10 +136,18 @@ export function remove_call(ctx, argv, named)
|
|||
continue;
|
||||
|
||||
for (let idx in val) {
|
||||
let orig_idx = idx;
|
||||
if (idx != "" + +idx) {
|
||||
let cur_idx = index(data, idx);
|
||||
if (cur_idx >= 0)
|
||||
idx = cur_idx + 1;
|
||||
else
|
||||
idx = null;
|
||||
} else if (+idx > length(data))
|
||||
idx = null;
|
||||
if (idx == null) {
|
||||
ctx.invalid_argument('Invalid value: %s', orig_idx);
|
||||
continue;
|
||||
}
|
||||
data[+idx - 1] = null;
|
||||
}
|
||||
|
@ -148,6 +156,8 @@ export function remove_call(ctx, argv, named)
|
|||
if (cur.attribute_allow_empty && !length(cur_obj[name]))
|
||||
delete cur_obj[name];
|
||||
}
|
||||
if (length(ctx.result.errors) > 0)
|
||||
return;
|
||||
call_change_cb(ctx, this, argv, named);
|
||||
return ctx.ok();
|
||||
};
|
||||
|
@ -249,6 +259,7 @@ function remove_params(orig_params)
|
|||
type: "enum",
|
||||
get_object: val.get_object,
|
||||
attribute: val.attribute ?? name,
|
||||
no_validate: true,
|
||||
value: param_values,
|
||||
force_helptext: true,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue