[pve-devel] [PATCH common] do not abort when an optional positional arg is missing

Dominik Csapak d.csapak at proxmox.com
Mon Jul 23 14:44:39 CEST 2018


e.g. pvenode acme account info [<name>]

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/JSONSchema.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index c9a9b1e..45ebf99 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1441,7 +1441,9 @@ sub get_options {
 		if ($arg_name eq 'extra-args') {
 		    $opts->{'extra-args'} = [];
 		} else {
-		    raise("not enough arguments\n", code => HTTP_BAD_REQUEST);
+		    my $pd = $schema->{properties}->{$arg_name};
+		    raise("not enough arguments\n", code => HTTP_BAD_REQUEST)
+			if !$pd->{optional};
 		}
 	    }
 	}
-- 
2.11.0





More information about the pve-devel mailing list