@@ -103,12 +103,23 @@ def populate_sub_parser_by_class(cls, sub_parser):
103
103
for x in cls .optionalCreateAttrs ]
104
104
105
105
elif action_name == UPDATE :
106
+ id_attr = cls .idAttr .replace ('_' , '-' )
107
+ sub_parser_action .add_argument ("--%s" % id_attr ,
108
+ required = True )
109
+
110
+ attrs = (cls .requiredUpdateAttrs
111
+ if cls .requiredUpdateAttrs is not None
112
+ else cls .requiredCreateAttrs )
106
113
[sub_parser_action .add_argument ("--%s" % x .replace ('_' , '-' ),
107
114
required = True )
108
- for x in cls .requiredCreateAttrs ]
115
+ for x in attrs ]
116
+
117
+ attrs = (cls .optionalUpdateAttrs
118
+ if cls .optionalUpdateAttrs is not None
119
+ else cls .optionalCreateAttrs )
109
120
[sub_parser_action .add_argument ("--%s" % x .replace ('_' , '-' ),
110
121
required = False )
111
- for x in cls . optionalCreateAttrs ]
122
+ for x in attrs ]
112
123
113
124
if cls in extra_actions :
114
125
for action_name in sorted (extra_actions [cls ]):
@@ -182,7 +193,7 @@ def do_delete(cls, gl, what, args):
182
193
if not cls .canDelete :
183
194
die ("%s objects can't be deleted" % what )
184
195
185
- o = do_get (cls , args , what , args )
196
+ o = do_get (cls , gl , what , args )
186
197
try :
187
198
o .delete ()
188
199
except Exception as e :
@@ -193,7 +204,7 @@ def do_update(cls, gl, what, args):
193
204
if not cls .canUpdate :
194
205
die ("%s objects can't be updated" % what )
195
206
196
- o = do_get (cls , args , what , args )
207
+ o = do_get (cls , gl , what , args )
197
208
try :
198
209
for k , v in args .items ():
199
210
o .__dict__ [k ] = v
0 commit comments