Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Unable to skip overwriting local snapshot using one line command #86

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/classes/Command/Pull.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
}
}

Expand Down