From d8c74d25eec4c6b48b9a192c3bc6f5e5383630e6 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 23 May 2021 18:58:06 +0700 Subject: [PATCH] allow skipping overwrite_local_copy using one line command --- src/classes/Command/Pull.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/classes/Command/Pull.php b/src/classes/Command/Pull.php index be3cbd9..32d25f1 100644 --- a/src/classes/Command/Pull.php +++ b/src/classes/Command/Pull.php @@ -46,7 +46,7 @@ protected function configure() { $this->addOption( 'confirm_ms_constant_update', null, InputOption::VALUE_NONE, 'Confirm updating constants in wp-config.php for multisite.' ); $this->addOption( 'suppress_instructions', null, InputOption::VALUE_NONE, 'Suppress instructions after successful installation.' ); - $this->addOption( 'overwrite_local_copy', null, InputOption::VALUE_NONE, 'Overwrite a local copy of the snapshot if there is one.' ); + $this->addOption( 'overwrite_local_copy', null, InputOption::VALUE_OPTIONAL, 'Overwrite a local copy of the snapshot if there is one.', false ); $this->addOption( 'include_files', null, InputOption::VALUE_OPTIONAL, 'Pull files within snapshot.', false ); $this->addOption( 'include_db', null, InputOption::VALUE_OPTIONAL, 'Pull database within snapshot.', false ); @@ -116,10 +116,11 @@ protected function execute( InputInterface $input, OutputInterface $output ) { } if ( ! empty( $remote_meta ) && ! empty( $local_meta ) ) { - if ( empty( $input->getOption( 'overwrite_local_copy' ) ) ) { + $overwrite_option = $input->getOption( 'overwrite_local_copy' ); + if ( false === $overwrite_option ) { $overwrite_local = $helper->ask( $input, $output, new ConfirmationQuestion( 'This snapshot exists locally. Do you want to overwrite it with the remote copy? (y/N) ', false ) ); } else { - $overwrite_local = true; + $overwrite_local = is_null( $overwrite_option ) || filter_var( $overwrite_option, FILTER_VALIDATE_BOOLEAN ); // is_null( $overwrite_option ) when `--overwrite_local_copy` is used without a value } }