@@ -21,6 +21,8 @@ Framework agnostic Command Line Interface utilities and helpers for PHP. Build C
2121
2222** IO:** [ Colorizer] ( #color ) · ; [ Cursor manipulator] ( #cursor ) · ; [ Stream writer] ( #writer ) · ; [ Stream reader] ( #reader )
2323
24+ ** Other:** [ Autocompletion] ( #autocompletion )
25+
2426## Installation
2527``` bash
2628composer require adhocore/cli
@@ -227,7 +229,7 @@ Same version number is passed to all attached Commands. So you can trigger versi
227229
228230### Shell
229231
230- Very thing shell wrapper that provides convenience methods around ` proc_open() ` .
232+ Very thin shell wrapper that provides convenience methods around ` proc_open() ` .
231233
232234#### Basic usage
233235
@@ -489,11 +491,69 @@ Whenever an exception is caught by `Application::handle()`, it will show a beaut
489491
490492![ Exception Preview] ( https://user-images.githubusercontent.com/2908547/44401057-8b350880-a577-11e8-8ca6-20508d593d98.png " Exception trace ")
491493
494+ ### Autocompletion
495+
496+ Any console applications that are built on top of ** adhocore/cli** can entertain autocomplete of commands and options in zsh shell with oh-my-zsh.
497+
498+ All you have to do is add one line to the end of ` ~/.oh-my-zsh/custom/plugins/ahccli/ahccli.plugin.zsh ` :
499+
500+ > ` compdef _ahccli <appname> `
501+
502+ Example: ` compdef _ahccli phint ` for [ phint] ( https://github.com/adhocore/phint ) .
503+
504+ That is cumbersome to perform manually, here's a complete command you can copy/paste/run:
505+
506+ #### One time setup
507+
508+ ``` sh
509+ mkdir -p ~ /.oh-my-zsh/custom/plugins/ahccli && cd ~ /.oh-my-zsh/custom/plugins/ahccli
510+
511+ [ -f ./ahccli.plugin.zsh ] || curl -sSLo ./ahccli.plugin.zsh https://raw.githubusercontent.com/adhocore/php-cli/master/ahccli.plugin.zsh
512+
513+ chmod 760 ./ahccli.plugin.zsh && cd -
514+ ```
515+
516+ ##### Load ahccli plugin
517+
518+ > This is also one time setup.
519+
520+ ``` sh
521+ # Open .zshrc
522+ nano ~ /.zshrc
523+
524+ # locate plugins=(... ...) and add ahccli
525+ plugins=(git ... ... ahccli)
526+
527+ # ... then save it (Ctrl + O)
528+ ```
529+
530+ #### Registering app
531+
532+ ``` sh
533+ # replace appname with real name eg: phint
534+ echo compdef _ahccli appname >> ~ /.oh-my-zsh/custom/plugins/ahccli/ahccli.plugin.zsh
535+ ```
536+
537+ > Of course you can add multiple apps, just change appname in above command
538+
539+ Then either restart the shell or source the plugin like so:
540+
541+ ``` sh
542+ source ~ /.oh-my-zsh/custom/plugins/ahccli/ahccli.plugin.zsh
543+ ```
544+
545+ #### Trigger autocomplete
546+
547+ ``` sh
548+ appname < tab> # autocompletes commands (phint <tab>)
549+ appname subcommand < tab> # autocompletes options for subcommand (phint init <tab>)
550+ ```
551+
492552### Related
493553
494- - [ adhocore/phalcon-ext] ( https://github.com/adhocore/phalcon-ext ) Phalcon extension using ` adhocore/cli `
495- - [ adhocore/phint] ( https://github.com/adhocore/phint ) PHP project scaffolding app using ` adhocore/cli `
496- - [ adhocore/type-hinter] ( https://github.com/adhocore/php-type-hinter ) Auto PHP7 typehinter tool using ` adhocore/cli `
554+ - [ adhocore/phalcon-ext] ( https://github.com/adhocore/phalcon-ext ) & middot ; Phalcon extension using ` adhocore/cli `
555+ - [ adhocore/phint] ( https://github.com/adhocore/phint ) & middot ; PHP project scaffolding app using ` adhocore/cli `
556+ - [ adhocore/type-hinter] ( https://github.com/adhocore/php-type-hinter ) & middot ; Auto PHP7 typehinter tool using ` adhocore/cli `
497557
498558### Contributors
499559
0 commit comments