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

Remove drush_get_global_options() #5046

Merged
merged 1 commit into from Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 0 additions & 78 deletions includes/drush.inc
Expand Up @@ -69,84 +69,6 @@ function drush_log($message, $type = LogLevel::INFO, $error = []) {
Drush::logger()->log($type, $message, $error);
}

/**
* Get the available global options. Used by list/help commands. All other users
* should pull options from $application.
*
* @param boolean $brief
* Return a reduced set of important options. Used by help command.
*
* @return
* An associative array containing the option definition as the key,
* and a descriptive array for each of the available options. The array
* elements for each item are:
*
* - short-form: The shortcut form for specifying the key on the commandline.
* - propagate: backend invoke will use drush_get_option to propagate this
* option, when set, to any other Drush command that is called.
* - context: The drush context where the value of this item is cached. Used
* by backend invoke to propagate values set in code.
* - never-post: If TRUE, backend invoke will never POST this item's value
* on STDIN; it will always be sent as a commandline option.
* - never-propagate: If TRUE, backend invoke will never pass this item on
* to the subcommand being executed.
* - local-context-only: Backend invoke will only pass this value on for local calls.
* - merge: For options such as $options['shell-aliases'] that consist of an array
* of items, make a merged array that contains all of the values specified for
* all of the contexts (config files) where the option is defined. The value is stored in
* the specified 'context', or in a context named after the option itself if the
* context flag is not specified.
* IMPORTANT: When the merge flag is used, the option value must be obtained via
* drush_get_context('option') rather than drush_get_option('option').
* - merge-pathlist: For options such as --include and --config, make a merged list
* of options from all contexts; works like the 'merge' flag, but also handles string
* values separated by the PATH_SEPARATOR.
* - merge-associative: Like 'merge-pathlist', but key values are preserved.
* - propagate-cli-value: Used to tell backend invoke to include the value for
* this item as specified on the cli. This can either override 'context'
* (e.g., propagate --include from cli value instead of DRUSH_INCLUDE context),
* or for an independent global setting (e.g. --user)
* - description: The help text for this item. displayed by `drush help`.
*/
function drush_get_global_options($brief = FALSE) {
$options['root'] = ['short-form' => 'r', 'short-has-arg' => TRUE, 'never-post' => TRUE, 'description' => "Drupal root directory to use.", 'example-value' => 'path'];
$options['uri'] = ['short-form' => 'l', 'short-has-arg' => TRUE, 'never-post' => TRUE, 'description' => 'URI of the drupal site to use.', 'example-value' => 'http://example.com:8888'];
$options['verbose'] = ['short-form' => 'v', 'context' => 'DRUSH_VERBOSE', 'description' => 'Display extra information about the command.', 'symfony-conflict' => TRUE];
$options['debug'] = ['short-form' => 'd', 'context' => 'DRUSH_DEBUG', 'description' => 'Display even more information.'];
$options['yes'] = ['short-form' => 'y', 'context' => 'DRUSH_AFFIRMATIVE', 'description' => "Assume 'yes' as answer to all prompts."];
$options['no'] = ['short-form' => 'n', 'context' => 'DRUSH_NEGATIVE', 'description' => "Assume 'no' as answer to all prompts."];
$options['help'] = ['short-form' => 'h', 'description' => "This help system."];

if (!$brief) {
$options['simulate'] = ['short-form' => 's', 'context' => 'DRUSH_SIMULATE', 'never-propagate' => TRUE, 'description' => "Simulate all relevant actions (don't actually change the system).", 'symfony-conflict' => TRUE];
$options['pipe'] = ['short-form' => 'p', 'hidden' => TRUE, 'description' => "Emit a compact representation of the command for scripting."];
$options['php'] = ['description' => "The absolute path to your PHP interpreter, if not 'php' in the path.", 'example-value' => '/path/to/file', 'never-propagate' => TRUE];
$options['interactive'] = ['short-form' => 'ia', 'description' => "Force interactive mode for commands run on multiple targets (e.g. `drush @site1,@site2 cc --ia`).", 'never-propagate' => TRUE];
$options['tty'] = ['hidden' => TRUE, 'description' => "Force allocation of tty for remote commands", 'never-propagate' => TRUE];
$options['quiet'] = ['short-form' => 'q', 'description' => 'Suppress non-error messages.'];
$options['include'] = ['short-form' => 'i', 'short-has-arg' => TRUE, 'context' => 'DRUSH_INCLUDE', 'never-post' => TRUE, 'propagate-cli-value' => TRUE, 'merge-pathlist' => TRUE, 'description' => "A list of additional directory paths to search for Drush commands. Commandfiles should be placed in a subfolder called 'Commands'.", 'example-value' => '/path/dir'];
$options['exclude'] = ['propagate-cli-value' => TRUE, 'never-post' => TRUE, 'merge-pathlist' => TRUE, 'description' => "A list of files and directory paths to exclude from consideration when searching for drush commandfiles.", 'example-value' => '/path/dir'];
$options['config'] = ['short-form' => 'c', 'short-has-arg' => TRUE, 'context' => 'DRUSH_CONFIG', 'never-post' => TRUE, 'propagate-cli-value' => TRUE, 'merge-pathlist' => TRUE, 'description' => "Specify an additional config file to load. See example.drush.yml", 'example-value' => '/path/file'];
$options['choice'] = ['description' => "Provide an answer to a multiple-choice prompt.", 'example-value' => 'number'];
$options['search-depth'] = ['description' => "Control the depth that drush will search for alias files.", 'example-value' => 'number'];
$options['ignored-modules'] = ['description' => "Exclude some modules from consideration when searching for drush command files.", 'example-value' => 'token,views'];
$options['no-label'] = ['description' => "Remove the site label that drush includes in multi-site command output (e.g. `drush @site1,@site2 status`)."];
$options['label-separator'] = ['description' => "Specify the separator to use in multi-site command output (e.g. `drush @sites pm-list --label-separator=',' --format=csv`).", 'example-value' => ','];
$options['show-invoke'] = ['description' => "Show all function names which could have been called for the current command. See drush_invoke()."];
$options['alias-path'] = ['context' => 'ALIAS_PATH', 'local-context-only' => TRUE, 'merge-pathlist' => TRUE, 'propagate-cli-value' => TRUE, 'description' => "Specifies the list of paths where drush will search for alias files.", 'example-value' => '/path/alias1:/path/alias2'];
$options['confirm-rollback'] = ['description' => 'Wait for confirmation before doing a rollback when something goes wrong.'];
$options['php-options'] = ['hidden' => TRUE, 'description' => "Options to pass to `php` when running drush. Only effective when specified in a site alias definition.", 'never-propagate' => TRUE, 'example-value' => '-d error_reporting="E_ALL"'];
$options['halt-on-error'] = ['propagate-cli-value' => TRUE, 'description' => "Manage recoverable errors. Values: 1=Execution halted. 0=Execution continues."];
$options['remote-os'] = ['hidden' => TRUE, 'description' => 'The operating system used on the remote host. Managed by site alias.', 'example-value' => 'linux'];
$options['strict'] = ['propagate' => TRUE, 'description' => 'Return an error on unrecognized options. --strict=0: Allow unrecognized options.'];
$options['command-specific'] = ['hidden' => TRUE, 'merge-associative' => TRUE, 'description' => 'Command-specific options.'];
$options['path-aliases'] = ['hidden' => TRUE, 'never-propagate' => TRUE, 'description' => 'Path aliases from site alias.'];
$options['ssh-options'] = ['never-propagate' => TRUE, 'description' => 'A string of extra options that will be passed to the ssh command', 'example-value' => '-p 100'];
$options['local'] = ['propagate' => TRUE, 'description' => 'Don\'t look in global locations for commandfiles, config, and site aliases'];
}
return $options;
}

/**
* Calls a given function, passing through all arguments unchanged.
*
Expand Down
13 changes: 10 additions & 3 deletions src/Commands/core/CoreCommands.php
Expand Up @@ -45,11 +45,18 @@ public function globalOptions($options = ['format' => 'table']): RowsOfFields

// Also document the keys that are recognized by PreflightArgs. It would be possible to redundantly declare
// those as global options. We don't do that for now, to avoid confusion.
$ancient = drush_get_global_options();
foreach (['config', 'alias-path', 'include', 'local', 'strict', 'ssh-options'] as $name) {
$ancient = [
'config' => 'Specify an additional config file to load. See example.drush.yml. Example: /path/file',
'alias-path' => 'Specifies additional paths where Drush will search for alias files. Example: /path/alias1:/path/alias2',
'include' => 'Additional directories to search for Drush commands. Commandfiles should be placed in a subdirectory called <info>Commands</info>. Example: path/dir',
'local' => 'Don\'t look outside the Composer project for Drush config.',
'strict' => 'Return an error on unrecognized options. --strict=0 allows unrecognized options.',
'ssh-options' => 'A string of extra options that will be passed to the ssh command. Example: -p 100',
];
foreach ($ancient as $name => $description) {
$rows[] = [
'name' => '--' . $name,
'description' => $ancient[$name]['description'],
'description' => $description,
];
}
usort($rows, function ($a, $b) {
Expand Down