completions/magento: remove sed dependency

This runs in about half the time, too.
This commit is contained in:
Mahmoud Al-Qudsi 2024-06-23 18:08:34 -05:00
parent 3c74f14569
commit 245ee466cb

View File

@ -15,10 +15,23 @@ end
###
function __fish_print_magento_modules -d "Lists all Magento modules"
test -f app/etc/config.php; or return
command -q sed; or return
set -l config_path app/etc/config.php
test -f $config_path; or return
command sed -n '/modules.*\[/,/\]/p' app/etc/config.php | sed -E '1d;$d;s/^\s*|\s*=>.*$|"|\'//g'
set -l in_modules 0
cat $config_path | \
while read -l line
if test "$in_modules" -eq 0
if string match -rq '[\'"]modules[\'"]\s*=>.*\[' -- $line
set in_modules 1;
end
else
if string match -rq '^\s*]\s*,\s*$' -- $line
break
end
string replace -rf '\s*[\'"](.*?)[\'"]\s*=>.*' '$1' -- $line
end
end
end
function __fish_print_magento_i18n_packing_modes -d "Shows all available packing modes"