@@ -185,6 +185,19 @@ def _parser_add_output_options(p):
185185 "section 'Output options' for more details." )
186186
187187
188+ def _parser_add_field_passthrough_opts (p ):
189+ p .add_argument ('--field' ,
190+ metavar = "FIELD=VALUE" , action = "append" , dest = "fields" ,
191+ help = "Manually specify a bugzilla API field. FIELD is "
192+ "the raw name used by the bugzilla instance. For example, if your "
193+ "bugzilla instance has a custom field cf_my_field, do:\n "
194+ " --field cf_my_field=VALUE" )
195+ p .add_argument ('--field-json' ,
196+ metavar = "JSONSTRING" , action = "append" , dest = "field_jsons" ,
197+ help = "Specify --field data as a JSON string. Example: --field-json "
198+ '\' {"cf_my_field": "VALUE", "cf_array_field": [1, 2]}\' ' )
199+
200+
188201def _parser_add_bz_fields (rootp , command ):
189202 cmd_new = (command == "new" )
190203 cmd_query = (command == "query" )
@@ -256,17 +269,7 @@ def _parser_add_bz_fields(rootp, command):
256269 p .add_argument ('-F' , '--fixed_in' ,
257270 help = "RHBZ 'Fixed in version' field" )
258271
259- # Put this at the end, so it sticks out more
260- p .add_argument ('--field' ,
261- metavar = "FIELD=VALUE" , action = "append" , dest = "fields" ,
262- help = "Manually specify a bugzilla API field. FIELD is "
263- "the raw name used by the bugzilla instance. For example, if your "
264- "bugzilla instance has a custom field cf_my_field, do:\n "
265- " --field cf_my_field=VALUE" )
266- p .add_argument ('--field-json' ,
267- metavar = "JSONSTRING" , action = "append" , dest = "field_jsons" ,
268- help = "Specify --field data as a JSON string. Example: --field-json "
269- '\' {"cf_my_field": "VALUE", "cf_array_field": [1, 2]}\' ' )
272+ _parser_add_field_passthrough_opts (p )
270273
271274 if not cmd_modify :
272275 _parser_add_output_options (rootp )
@@ -405,6 +408,8 @@ def _setup_action_attach_parser(subparsers):
405408 p .add_argument ('--private' , action = 'store_true' , default = False ,
406409 help = 'Mark new comment as private' )
407410
411+ _parser_add_field_passthrough_opts (p )
412+
408413
409414def _setup_action_login_parser (subparsers ):
410415 usage = 'bugzilla login [--api-key] [username [password]]'
@@ -1172,6 +1177,8 @@ def _do_set_attach(bz, opt, parser):
11721177 kwargs ["is_private" ] = True
11731178 desc = opt .desc or os .path .basename (fileobj .name )
11741179
1180+ _merge_field_opts (kwargs , opt .fields , opt .field_jsons , parser )
1181+
11751182 # Upload attachments
11761183 for bugid in opt .ids :
11771184 attid = bz .attachfile (bugid , fileobj , desc , ** kwargs )
0 commit comments