Separate positional and assoc arguments.

This commit is contained in:
Justin Shreve 2017-02-10 08:38:43 -08:00
parent b58e26b0ab
commit 700026c2ab
1 changed files with 12 additions and 8 deletions

View File

@ -92,6 +92,7 @@ class WC_CLI_Runner {
'attribute_id' => __( 'Attribute ID.', 'woocommerce' ), 'attribute_id' => __( 'Attribute ID.', 'woocommerce' ),
); );
$rest_command->set_supported_ids( $supported_ids ); $rest_command->set_supported_ids( $supported_ids );
$positional_args = array_merge( array( 'id' ), array_keys( $supported_ids ) );
$parent = "wc {$route_data['schema']['title']}"; $parent = "wc {$route_data['schema']['title']}";
$supported_commands = array(); $supported_commands = array();
@ -137,9 +138,10 @@ class WC_CLI_Runner {
foreach ( $supported_ids as $id_name => $id_desc ) { foreach ( $supported_ids as $id_name => $id_desc ) {
if ( strpos( $route, '<' . $id_name . '>' ) !== false ) { if ( strpos( $route, '<' . $id_name . '>' ) !== false ) {
$synopsis[] = array( $synopsis[] = array(
'name' => $id_name, 'name' => $id_name,
'type' => 'positional', 'type' => 'positional',
'description' => $id_desc, 'description' => $id_desc,
'optional' => false,
); );
} }
} }
@ -154,12 +156,14 @@ class WC_CLI_Runner {
} }
foreach ( $endpoint_args as $name => $args ) { foreach ( $endpoint_args as $name => $args ) {
$arg_regs[] = array( if ( ! in_array( $name, $positional_args ) ) {
'name' => $name, $arg_regs[] = array(
'type' => 'assoc', 'name' => $name,
'description' => ! empty( $args['description'] ) ? $args['description'] : '', 'type' => 'assoc',
'optional' => empty( $args['required'] ) ? true : false, 'description' => ! empty( $args['description'] ) ? $args['description'] : '',
); 'optional' => empty( $args['required'] ) ? true : false,
);
}
} }
foreach ( $arg_regs as $arg_reg ) { foreach ( $arg_regs as $arg_reg ) {