X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;h=793ec60c7465d27a04359b7d3387c17054fbf18b;hp=41a66528681e1c40812531798826462bb90c3c48;hb=03c1e2a061c6e47f9ffeacd379a69fb670cb7f4d;hpb=4842b6510546f76906b216cb05d98ec9768f9e8e diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 41a6652..793ec60 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -121,6 +121,22 @@ sub get_format { return $format_list->{$format}; } +my $renderer_hash = {}; + +sub register_renderer { + my ($name, $code) = @_; + + die "renderer '$name' already registered\n" + if $renderer_hash->{$name}; + + $renderer_hash->{$name} = $code; +} + +sub get_renderer { + my ($name) = @_; + return $renderer_hash->{$name}; +} + # register some common type for pve register_format('string', sub {}); # allow format => 'string-list' @@ -1065,6 +1081,11 @@ my $default_schema_noref = { optional => 1, description => "This provides the title of the property", }, + renderer => { + type => "string", + optional => 1, + description => "This is used to provide rendering hints to format cli command output.", + }, requires => { type => [ "string", "object" ], optional => 1,