From c3618cad478b172beb626d034ff29390612381d1 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Fri, 10 Jul 2020 07:21:05 -0700 Subject: [PATCH 1/2] Added the `instance_id` parameter to the CLI runner This is used for shipping zone methods and so we need to be able to parse it too! --- includes/cli/class-wc-cli-runner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/cli/class-wc-cli-runner.php b/includes/cli/class-wc-cli-runner.php index a4194b8139b..c9c9067ba86 100644 --- a/includes/cli/class-wc-cli-runner.php +++ b/includes/cli/class-wc-cli-runner.php @@ -114,6 +114,7 @@ class WC_CLI_Runner { 'attribute_id' => __( 'Attribute ID.', 'woocommerce' ), 'zone_id' => __( 'Zone ID.', 'woocommerce' ), 'id' => __( 'ID.', 'woocommerce' ), + 'instance_id' => __( 'Instance ID.', 'woocommerce' ), ); $rest_command->set_supported_ids( $supported_ids ); $positional_args = array_keys( $supported_ids ); From 933cdd7a7b2784d7ca0cabd5026af7c63011a48f Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Fri, 10 Jul 2020 14:16:30 -0700 Subject: [PATCH 2/2] Removed the default `id` field added to all CLI commands Some of our endpoints don't have an "" parameter but we're expecting one in the CLI. Since the `id` is already part of the supported IDs we don't actually need this since it will pull it from the route. --- includes/cli/class-wc-cli-runner.php | 10 +--------- tests/cli/bin/install-package-tests.sh | 1 + 2 files changed, 2 insertions(+), 9 deletions(-) mode change 100644 => 100755 tests/cli/bin/install-package-tests.sh diff --git a/includes/cli/class-wc-cli-runner.php b/includes/cli/class-wc-cli-runner.php index c9c9067ba86..dd1e06d6b24 100644 --- a/includes/cli/class-wc-cli-runner.php +++ b/includes/cli/class-wc-cli-runner.php @@ -113,8 +113,8 @@ class WC_CLI_Runner { 'refund_id' => __( 'Refund ID.', 'woocommerce' ), 'attribute_id' => __( 'Attribute ID.', 'woocommerce' ), 'zone_id' => __( 'Zone ID.', 'woocommerce' ), - 'id' => __( 'ID.', 'woocommerce' ), 'instance_id' => __( 'Instance ID.', 'woocommerce' ), + 'id' => __( 'The ID for the resource.', 'woocommerce' ), ); $rest_command->set_supported_ids( $supported_ids ); $positional_args = array_keys( $supported_ids ); @@ -167,14 +167,6 @@ class WC_CLI_Runner { $ids[] = $id_name; } } - if ( in_array( $command, array( 'delete', 'get', 'update' ), true ) && ! in_array( 'id', $ids, true ) ) { - $synopsis[] = array( - 'name' => 'id', - 'type' => 'positional', - 'description' => __( 'The id for the resource.', 'woocommerce' ), - 'optional' => false, - ); - } foreach ( $endpoint_args as $name => $args ) { if ( ! in_array( $name, $positional_args, true ) || strpos( $route, '<' . $id_name . '>' ) === false ) { diff --git a/tests/cli/bin/install-package-tests.sh b/tests/cli/bin/install-package-tests.sh old mode 100644 new mode 100755 index e7e5979ac9a..7a6252efa76 --- a/tests/cli/bin/install-package-tests.sh +++ b/tests/cli/bin/install-package-tests.sh @@ -3,6 +3,7 @@ set -ex PACKAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )" +WP_CLI_BIN_DIR="${PACKAGE_DIR}/bin" download() { if [ `which curl` ]; then