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

--yes and --no-interaction do not behave identically #3082

Closed
danepowell opened this issue Oct 20, 2017 · 4 comments
Closed

--yes and --no-interaction do not behave identically #3082

danepowell opened this issue Oct 20, 2017 · 4 comments

Comments

@danepowell
Copy link
Contributor

I'm using Drush 9.0.0-beta7.

According to docs, previous comments, and this issue, the --yes and --no-interaction options should behave identically. In practice, they do not, at least for the site install command.

drush si --yes installs a site without any further interaction from the user, because it assumes a 'yes' response to whether to drop the database prior to install
drush si --no-interaction fails because it assumes a 'no' response to whether to drop the database

Ironically, for the moment this is actually a good thing, because if both of these were to behave like --no-interaction and assume 'no', there would be no way to force a site install! But we definitely need to figure out what the intended behavior is here.

@greg-1-anderson
Copy link
Member

Hm, I prefer the behavior you describe. If this is repeatable, we should change the docs.

This is handled here: https://github.com/drush-ops/drush/blob/master/src/Style/DrushStyle.php#L14

Symfony defines --no-interaction as "answer all questions using the default value". The downside of replicating this behavior everywhere is that --yes would not necessarily cause a confirmation to pass if the default value is 'no'. However, the confirm method above is derived from SymfonyStyle, so as long as we can inject our object into our dependencies, then the behavior will be consistent.

So, lets fix the docs.

@weitzman
Copy link
Member

I think this is a happy accident that may need to be fixed. Specfically, look at how we set the value of DRUSH_NEGATIVE at

$no = $input->getOption('no-interaction', false);
$pipe = $input->getOption('pipe', false);
$quiet = $input->getOption('quiet', false);
$simulate = Drush::simulate();
drush_set_context('DRUSH_VERBOSE', $verbose || $debug);
drush_set_context('DRUSH_DEBUG', $debug);
drush_set_context('DRUSH_DEBUG_NOTIFY', $verbose && $debug);
drush_set_context('DRUSH_SIMULATE', $simulate);
// Backend implies affirmative unless negative is explicitly specified
drush_set_context('DRUSH_NEGATIVE', $no);

This overloading of --no-interaction is going to bite us later, no?

@weitzman
Copy link
Member

See #3084 where I stop overloading -n|--no-interaction and also modernize a bit

@weitzman
Copy link
Member

Lets discuss in #3084.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants