@@ -109,7 +109,7 @@ DECLARABLE = {
109
109
'vhost' : {'mandatory' : ['name' ],
110
110
'optional' : {'tracing' : None }},
111
111
'user' : {'mandatory' : ['name' , ['password' , 'password_hash' ], 'tags' ],
112
- 'optional' : {}},
112
+ 'optional' : {'hashing_algorithm' : None }},
113
113
'permission' : {'mandatory' : ['vhost' , 'user' , 'configure' , 'write' , 'read' ],
114
114
'optional' : {}},
115
115
'parameter' : {'mandatory' : ['component' , 'name' , 'value' ],
@@ -258,10 +258,22 @@ For more help use the help subcommand:
258
258
rabbitmqadmin help config # For help with the configuration file
259
259
"""
260
260
261
+ def fmt_required_flag (val ):
262
+ # when one of the options is required, e.g.
263
+ # password vs. password_hash
264
+ if type (val ) is list :
265
+ # flag1=... OR flag2=... OR flag3=...
266
+ return "=... OR " .join (val )
267
+ else :
268
+ return val
269
+
270
+ def fmt_optional_flag (val ):
271
+ return val
272
+
261
273
def fmt_usage_stanza (root , verb ):
262
274
def fmt_args (args ):
263
- res = " " .join (["{0}=..." .format (a ) for a in args ['mandatory' ]])
264
- opts = " " .join ("{0}=..." .format (o ) for o in args ['optional' ].keys ())
275
+ res = " " .join (["{0}=..." .format (fmt_required_flag ( a ) ) for a in args ['mandatory' ]])
276
+ opts = " " .join ("{0}=..." .format (fmt_optional_flag ( o ) ) for o in args ['optional' ].keys ())
265
277
if opts != "" :
266
278
res += " [{0}]" .format (opts )
267
279
return res
@@ -728,17 +740,20 @@ class Management:
728
740
upload [k ] = optional [k ]
729
741
for arg in args :
730
742
assert_usage ("=" in arg ,
731
- 'Argument "{0}" not in format name=value' .format (arg ))
743
+ 'Argument "{0}" not in the name=value format ' .format (arg ))
732
744
(name , value ) = arg .split ("=" , 1 )
745
+ # flatten the list of mandatory keys
733
746
mandatory_keys = []
734
747
for key in mandatory :
735
748
if type (key ) is list :
736
749
for subkey in key :
737
750
mandatory_keys .append (subkey )
738
751
else :
739
752
mandatory_keys .append (key )
753
+
740
754
assert_usage (name in mandatory_keys or name in optional .keys (),
741
- 'Argument "{0}" not recognised' .format (name ))
755
+ 'Argument "{0}" is not recognised' .format (name ))
756
+
742
757
if 'json' in obj and name in obj ['json' ]:
743
758
upload [name ] = self .parse_json (value )
744
759
else :
@@ -748,10 +763,10 @@ class Management:
748
763
a_set = set (m )
749
764
b_set = set (upload .keys ())
750
765
assert_usage ((a_set & b_set ),
751
- 'mandatory one- of arguments "{0}" required' .format (m ))
766
+ 'one of mandatory arguments "{0}" is required' .format (m ))
752
767
else :
753
768
assert_usage (m in upload .keys (),
754
- 'mandatory argument "{0}" required' .format (m ))
769
+ 'mandatory argument "{0}" is required' .format (m ))
755
770
if 'vhost' not in mandatory :
756
771
upload ['vhost' ] = self .options .vhost or self .options .declare_vhost
757
772
uri_args = {}
0 commit comments