Skip to content

Commit

Permalink
Move autocompletion into res folder
Browse files Browse the repository at this point in the history
More space in project root directory and align it's name with the other
autocompletion files (fish, zsh).

Register symfony-console-autocomplete as a development requirement.

Reflect changes in docs.

Make autocompletion compiling a first-level command.

Integrate with Travis build.
  • Loading branch information
ktomk committed Feb 8, 2017
1 parent cc6fc14 commit e24f1f1
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 76 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
matrix:
- SCRIPT_JOB="PHP-CS-FIXER"
- SCRIPT_JOB="BUILDSH"
- SCRIPT_JOB="BASH-AUTOCOMPLETION"
- MAGENTO_VERSION="magento-mirror-1.4.2.0" INSTALL_SAMPLE_DATA=yes
- MAGENTO_VERSION="magento-mirror-1.5.1.0" INSTALL_SAMPLE_DATA=yes
- MAGENTO_VERSION="magento-mirror-1.6.2.0" INSTALL_SAMPLE_DATA=yes
Expand Down Expand Up @@ -77,14 +78,20 @@ matrix:
env: SCRIPT_JOB="PHP-CS-FIXER"
- php: 5.6
env: SCRIPT_JOB="BUILDSH"
- php: 5.6
env: SCRIPT_JOB="BASH-AUTOCOMPLETION"
- php: 7.0
env: SCRIPT_JOB="PHP-CS-FIXER"
- php: 7.0
env: SCRIPT_JOB="BUILDSH"
- php: 7.0
env: SCRIPT_JOB="BASH-AUTOCOMPLETION"
- php: 7.1
env: SCRIPT_JOB="PHP-CS-FIXER"
- php: 7.1
env: SCRIPT_JOB="BUILDSH"
- php: 7.1
env: SCRIPT_JOB="BASH-AUTOCOMPLETION"
# Run with current PHP 5.6 and PHP 7.0 version (as not set in matrix)
- php: 5.6
env: MAGENTO_VERSION="magento-mirror-1.9.2.4" DB=mysql INSTALL_SAMPLE_DATA=no
Expand Down
1 change: 1 addition & 0 deletions bin/compile-bash-autocompletion
3 changes: 2 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Build phar with:
<include name="**/**" />
</fileset>
<fileset dir="res" id="res_folder">
<include name="**/**" />
<include name="dev/**" />
<include name="twig/**" />
</fileset>
<fileset dir="vendor" id="vendor_folder">
<include name="**/**" />
Expand Down
65 changes: 0 additions & 65 deletions build/bin/autocompletion-make.sh

This file was deleted.

40 changes: 40 additions & 0 deletions build/bin/compile-bash-autocompletion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#
# compile-bash-autocompletion
#
# generate bash autocompletion file for magerun
#
set -euo pipefail
IFS=$'\n\t'

header()
{
cat <<EOF
#!/bin/bash
# Installation:
# Copy to /etc/bash_completion.d/n98-magerun.phar
# or
# Append to ~/.bash_completion
# open new or restart existing shell session
EOF
}

base=magerun
name=n98-${base}
outfile=res/autocompletion/bash/n98-magerun.phar.bash

if [[ ! -e "bin/${name}" ]]; then
echo >2 "error: could not find 'bin/${name}' script"
exit 1
fi

echo "creating bash autocomplete file (this takes a little moment).."

header > "${outfile}"
vendor/bin/symfony-autocomplete -- "bin/${name}" \
| sed '1d ; $ s/$/.phar '"${name} ${base}"'/' \
>> "${outfile}"
# sed: remove first line and expand last line to more command names (aliases)

echo "updated \"${outfile}\"."
4 changes: 4 additions & 0 deletions build/travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ case "${SCRIPT_JOB}" in
build/travis/build.sh
;;

"BASH-AUTOCOMPLETION" )
bin/compile-bash-autocompletion
;;

esac
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"twig/twig": "~1.0"
},
"require-dev": {
"bamarni/symfony-console-autocomplete": "^1.2.0",
"friendsofphp/php-cs-fixer": "~1.12.0",
"mikey179/vfsStream": "~1.4",
"phing/phing": "~2.10.0",
Expand Down
40 changes: 39 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ Prints stored cache entry by ID.
If value is serialized you can force a pretty output with --unserialize option.
Toggle CMS Block
"""""""""""
""""""""""""""""
Toggle "is_active" on a cms block
Expand Down Expand Up @@ -1710,19 +1710,36 @@ Script argument is optional. If you don't specify any you can select one from a
Autocompletion
--------------
Files for autocompletion with Magerun can be found inside the folder `res/autocompletion`, In
the following some more information about two specific ones (Bash, Phpstorm), there are
more (e.g. Fish, Zsh).
Bash
""""
Copy the file **bash_complete** to **n98-magerun.phar** in your bash autocomplete folder.
In my Ubuntu system this can be done with the following command:
Bash completion is available pre-generated, all commands and their respective
options are availble on tab. To get completion for an otion type two dashes
("--") and then tab.
To install the completion files, copy **n98-magerun.phar.bash** to your bash
compatdir folder for autocompletion.
On my Ubuntu system this can be done with the following command:
.. code-block:: sh
$ sudo cp autocompletion/bash/bash_complete /etc/bash_completion.d/n98-magerun.phar
# cp res/autocompletion/bash/n98-magerun.phar.bash /etc/bash_completion.d
The concrete folder can be obtained via pkg-config::
.. code-block:: sh
# pkg-config --variable=compatdir bash-completion
Detailed information is available in the bash-completions FAQ: https://github.com/scop/bash-completion#faq
PHPStorm 8.0.*
""""""""
""""""""""""""
A commandline tool autocompletion XML file for PHPStorm exists in subfolder **autocompletion/phpstorm**.
Copy **n98_magerun.xml** into your phpstorm config folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ _n98-magerun()
opts="${opts} --name --description --author --type --homepage --require --require-dev --stability --license --repository"
;;
composer:install)
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --no-plugins --no-custom-installers --no-autoloader --no-scripts --no-progress --optimize-autoloader --classmap-authoritative --ignore-platform-reqs"
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs"
;;
composer:require)
opts="${opts} --dev --prefer-source --prefer-dist --no-plugins --no-progress --no-update --update-no-dev --update-with-dependencies --ignore-platform-reqs --sort-packages --optimize-autoloader --classmap-authoritative"
opts="${opts} --dev --prefer-source --prefer-dist --no-progress --no-suggest --no-update --no-scripts --update-no-dev --update-with-dependencies --ignore-platform-reqs --prefer-stable --prefer-lowest --sort-packages --optimize-autoloader --classmap-authoritative --apcu-autoloader"
;;
composer:search)
opts="${opts} --only-name"
opts="${opts} --only-name --type"
;;
composer:update)
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --lock --no-plugins --no-custom-installers --no-autoloader --no-scripts --no-progress --with-dependencies --optimize-autoloader --classmap-authoritative --ignore-platform-reqs --prefer-stable --prefer-lowest --interactive --root-reqs"
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --lock --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --with-dependencies --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs --prefer-stable --prefer-lowest --interactive --root-reqs"
;;
composer:validate)
opts="${opts} --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e24f1f1

Please sign in to comment.