Skip to content

Commit

Permalink
Move autocompletion into res folder
Browse files Browse the repository at this point in the history
And forward port of Magerun static bash automcompletion compilation.

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 11, 2017
1 parent be643e7 commit f7c5e77
Show file tree
Hide file tree
Showing 11 changed files with 529 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
matrix:
- SCRIPT_JOB="PHP-CS-FIXER"
- SCRIPT_JOB="BUILDSH"
- SCRIPT_JOB="BASH-AUTOCOMPLETION"
- MAGENTO_VERSION="magento-ce-2.1.4" INSTALL_SAMPLE_DATA=0
- MAGENTO_VERSION="magento-ce-2.1.3" INSTALL_SAMPLE_DATA=0
- MAGENTO_VERSION="magento-ce-2.1.2" INSTALL_SAMPLE_DATA=0
Expand Down Expand Up @@ -58,6 +59,8 @@ matrix:
env: SCRIPT_JOB="PHP-CS-FIXER"
- php: 7.1
env: SCRIPT_JOB="BUILDSH"
- php: 7.1
env: SCRIPT_JOB="BASH-AUTOCOMPLETION"

before_install:
- phpenv config-rm xdebug.ini
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RECENT CHANGES
* Imp: Support NULL values in config:set and config:get (by Tom Klingenberg, #208)
* Imp: Better handle incomplete Magento 2 installments (by Tom Klingenberg)
* Imp: Dispatch adminhtml_cache_flush_all with cache:flush (report by Viktor Steinwand, #263)
* New: Compilation of the bash autocomplete-file (by Tom Klingenberg)
* New: Add current Magento2 versions (thanks Pieter Hoste, #270)
* New: Add current Magento2 versions (by Tom Klingenberg)
* New: Add sys:cron:schedule command (by Pieter Hoste, #257)
Expand Down
1 change: 1 addition & 0 deletions bin/compile-bash-autocompletion
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=magerun2
name=n98-${base}
outfile=res/autocompletion/bash/n98-magerun2.phar.bash

if [[ ! -e "bin/${name}" ]]; then
>&2 echo "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 @@ -51,4 +51,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.

43 changes: 37 additions & 6 deletions readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,37 @@ You can now use the tools:
$ n98-magerun2 {command}
Autocompletion
--------------

Files for autocompletion with Magerun can be found inside the folder `res/autocompletion`, In
the following some more information about a specific one (Bash), there are
more (e.g. Fish, Zsh).

Bash
""""

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
# 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

Usage / Commands
----------------

Expand Down Expand Up @@ -298,7 +329,7 @@ If no code is specified, all cache types will be enabled.
Run `cache:list` command to see all codes.
EAV Attributes
"""""""""""""""""
""""""""""""""
View the data for a particular attribute:
Expand All @@ -307,7 +338,7 @@ View the data for a particular attribute:
$ n98-magerun2.phar eav:attribute:view [--format[="..."]] entityType attributeCode
Generate Gift Card Pool
"""""""""""""""""
"""""""""""""""""""""""
Generates a new gift card pool.
Expand All @@ -316,7 +347,7 @@ Generates a new gift card pool.
$ n98-magerun2.phar giftcard:pool:generate
Create a Gift Card
"""""""""""""""""
""""""""""""""""""
.. code-block:: sh
Expand All @@ -326,14 +357,14 @@ You may specify a website ID or use the default. You may also optionally add an
using the `--expires` option. Dates should be in `YYYY-MM-DD` format.
View Gift Card Information
"""""""""""""""""
""""""""""""""""""""""""""
.. code-block:: sh
$ n98-magerun2.phar giftcard:info [--format[="..."]] [code]
Remove a Gift Card
"""""""""""""""""
""""""""""""""""""
.. code-block:: sh
Expand All @@ -354,7 +385,7 @@ Compares module version with saved setup version in `setup_module` table and dis
Change Setup Version
""""""""""""""""""""
Changes the version of a module. This command is useful if you want to re-run an upgrade script again possibly for
Changes the version of a module. This command is useful if you want to re-run an upgrade script again possibly for
debugging. Alternatively you would have to alter the row in the database manually.
.. code-block:: sh
Expand Down
Loading

0 comments on commit f7c5e77

Please sign in to comment.