[pbs-devel] [RFC proxmox 1/2] schema: print item type-text instead of <array>

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Sep 15 15:36:33 CEST 2021


this is only used for CLI synopsis/usage strings, the API viewer already
prints the full type text in a correct format. the old variant was also
rather misleading, since on the CLI we don't pass in an array, but each
item as its own parameter.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
noticed this while working on the pull/sync filtering series, but it
affects quite a lot of stuff, among other things the Updater/Deleteable
CLI, e.g. from `man proxmox-backup-manager`:

       --delete <array>
                     List of properties to delete.

vs.

       --delete disable|validation-delay
                     List of properties to delete.

but some of them might only have <string> as the item type text, which
is not much nicer :-/

the whole "List of .." is confusing anyway, but not easily solvable,
since the description is used for
- API dump/viewer (where it is a list/array of ..)
- usage message/man pages (where it's a parameter that gives a single
  element, but it might be passed in multiple times to construct an
  array)

also for some common occurences, the item description is too generic,
and it's not possible to override the description for external types
with the current api macro.

 proxmox/src/api/format.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proxmox/src/api/format.rs b/proxmox/src/api/format.rs
index 7f16e93..a362b21 100644
--- a/proxmox/src/api/format.rs
+++ b/proxmox/src/api/format.rs
@@ -120,7 +120,7 @@ pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> S
             _ => String::from("<number>"),
         },
         Schema::Object(_) => String::from("<object>"),
-        Schema::Array(_) => String::from("<array>"),
+        Schema::Array(schema) => get_schema_type_text(schema.items, _style),
         Schema::AllOf(_) => String::from("<object>"),
     }
 }
-- 
2.30.2






More information about the pbs-devel mailing list