[pve-devel] [PATCH common 2/2] generate_typetext: handle enums and booleans automatically

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Mar 30 12:09:53 CEST 2016


---
 src/PVE/PodParser.pm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/PVE/PodParser.pm b/src/PVE/PodParser.pm
index a967549..febcfd2 100644
--- a/src/PVE/PodParser.pm
+++ b/src/PVE/PodParser.pm
@@ -49,8 +49,11 @@ sub generate_typetext {
     my $typetext = '';
     my (@optional, @required);
     foreach my $key (sort keys %$schema) {
-	next if !$schema->{$key}->{format_description} &&
-	        !$schema->{$key}->{typetext};
+	my $entry = $schema->{$key};
+	next if !$entry->{format_description} &&
+	        !$entry->{typetext} &&
+	        !$entry->{enum} &&
+	        $entry->{type} ne 'boolean';
 	if ($schema->{$key}->{optional}) {
 	    push @optional, $key;
 	} else {
@@ -66,11 +69,17 @@ sub generate_typetext {
 	    $key = $alias;
 	    $entry = $schema->{$key};
 	}
-	if (my $desc = $entry->{format_description}) {
+	if (!defined($entry->{typetext})) {
 	    $typetext .= $entry->{default_key} ? "[$key=]" : "$key=";
+	}
+	if (my $desc = $entry->{format_description}) {
 	    $typetext .= "<$desc>";
 	} elsif (my $text = $entry->{typetext}) {
 	    $typetext .= $text;
+	} elsif (my $enum = $entry->{enum}) {
+	    $typetext .= '<' . join('|', @$enum) . '>';
+	} elsif ($entry->{type} eq 'boolean') {
+	    $typetext .= '<1|0>';
 	} else {
 	    die "internal error: neither format_description nor typetext found";
 	}
-- 
2.1.4





More information about the pve-devel mailing list