mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 11:22:52 +08:00
completions/magento: Fixes module aggregation for module related commands (#10446)
* completions/magento: Fixes module aggregation for module related commmands Previousely when attempting completion for commands `module:enable`, `mmodule:disable` and `module:uninstall` and error would be disaplyed, stating that "magento" was not found. Upon inspection of the issue in the related completion script it became clear that: 1. The shell command `magento` does not exist as the CLI script of Magentoresides under `bin/magento`. 2. The module aggregation would not work after referncing the appropriate CLI command as an undeclared variable was being introspected. 3. Using Magento's CLI command took too long to respond as it has to bootstrap the whole Magento stack in order to deliver modules. Thus the whole aggregation was rewritten to a form that actually works and reduces the aggregation to reading the appropriate information directly from the configuration file, provided that the file exists and PHP is installed. * completions/magento: Refactors module aggregation for module related commmands to not use PHP script Executing random scripts from fish completion poses a threat to the system. While this would indicate that the Magento installation has been corrupted, it still is better to not run `app/etc/config.php` to get hold of the modules. Thus the module aggregation was rewritten to make use of `sed` instead, which has the additional benefit of being faster than using PHP.
This commit is contained in:
parent
2f46186f2b
commit
3c74f14569
|
@ -15,13 +15,10 @@ end
|
|||
###
|
||||
|
||||
function __fish_print_magento_modules -d "Lists all Magento modules"
|
||||
set -l modules (magento module:status)
|
||||
test -f app/etc/config.php; or return
|
||||
command -q sed; or return
|
||||
|
||||
for i in $test
|
||||
if test -n "$i" -a "$i" != None
|
||||
echo $i
|
||||
end
|
||||
end
|
||||
command sed -n '/modules.*\[/,/\]/p' app/etc/config.php | sed -E '1d;$d;s/^\s*|\s*=>.*$|"|\'//g'
|
||||
end
|
||||
|
||||
function __fish_print_magento_i18n_packing_modes -d "Shows all available packing modes"
|
||||
|
@ -497,6 +494,13 @@ __fish_magento_register_command_option module:enable -f -s f -l force -d "Bypass
|
|||
__fish_magento_register_command_option module:enable -f -l all -d "Enable all modules"
|
||||
__fish_magento_register_command_option module:enable -f -s c -l clear-static-content -d "Clear generated static view files. Necessary if module(s) have static view files"
|
||||
|
||||
#
|
||||
# module:status
|
||||
#
|
||||
__fish_magento_register_command_option module:status -f -a "(__fish_print_magento_modules)" -d "Module name"
|
||||
__fish_magento_register_command_option module:status -f -l enabled -d "Print only enabled modules"
|
||||
__fish_magento_register_command_option module:status -f -l disabled -d "Print only disabled modules"
|
||||
|
||||
#
|
||||
# module:uninstall
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue
Block a user