diff options
| author | Felix Fietkau | 2025-04-03 09:51:41 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-04-11 08:41:12 +0000 |
| commit | 37c80e61ee6f8fb513639a89b42dcdaaadb3d156 (patch) | |
| tree | 3a44c47ab6b7f819ee6f30787c966eabc714387a | |
| parent | c166cb96615d8a74e91d0de40da01ffa10a89c27 (diff) | |
| download | openwrt-37c80e61ee6f8fb513639a89b42dcdaaadb3d156.tar.gz | |
cli: extend remove call to allow passing values directly
This simplifies script or API usage of this command to remove values directly
without having to calculate the index
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | package/utils/cli/files/usr/share/ucode/cli/object-editor.uc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc b/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc index 0a44754064..1f36ee9d07 100644 --- a/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc +++ b/package/utils/cli/files/usr/share/ucode/cli/object-editor.uc @@ -135,8 +135,14 @@ export function remove_call(ctx, argv, named) if (!data) continue; - for (let idx in val) + for (let idx in val) { + if (idx != "" + +idx) { + let cur_idx = index(data, idx); + if (cur_idx >= 0) + idx = cur_idx + 1; + } data[+idx - 1] = null; + } cur_obj[name] = filter(data, (v) => v != null); if (cur.attribute_allow_empty && !length(cur_obj[name])) |