@@ -21,6 +21,8 @@ Framework agnostic Command Line Interface utilities and helpers for PHP. Build C
21
21
22
22
** IO:** [ Colorizer] ( #color ) · ; [ Cursor manipulator] ( #cursor ) · ; [ Stream writer] ( #writer ) · ; [ Stream reader] ( #reader )
23
23
24
+ ** Other:** [ Autocompletion] ( #autocompletion )
25
+
24
26
## Installation
25
27
``` bash
26
28
composer require adhocore/cli
@@ -489,6 +491,48 @@ Whenever an exception is caught by `Application::handle()`, it will show a beaut
489
491
490
492
![ Exception Preview] ( https://user-images.githubusercontent.com/2908547/44401057-8b350880-a577-11e8-8ca6-20508d593d98.png " Exception trace ")
491
493
494
+ ### Autocompletion
495
+
496
+ Any console line apps 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/phpcli/phpcli.plugin.zsh ` :
499
+
500
+ > ` compdef _phpcli <appname> `
501
+
502
+ Example: ` compdef _phpcli 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/phpcli && cd ~ /.oh-my-zsh/custom/plugins/phpcli
510
+ [ -f ./phpcli.plugin.zsh ] || curl -sSLo ./phpcli.plugin.zsh https://raw.githubusercontent.com/adhocore/php-cli/master/phpcli.plugin.zsh
511
+ chmod +x ./phpcli.plugin.zsh && cd -
512
+ ```
513
+
514
+ #### Registering app
515
+
516
+ ``` sh
517
+ # replace appname with real name eg: phint
518
+ echo compdef _phpcli appname >> ~ /.oh-my-zsh/custom/plugins/phpcli/phpcli.plugin.zsh
519
+ ```
520
+
521
+ > Of course you can add multiple apps, just change appname in above command
522
+
523
+ Then either restart the shell or source the plugin like so:
524
+
525
+ ``` sh
526
+ source ~ /.oh-my-zsh/custom/plugins/phpcli/phpcli.plugin.zsh
527
+ ```
528
+
529
+ #### Trigger autocomplete
530
+
531
+ ``` sh
532
+ appname < tab> # autocompletes commands (phint <tab>)
533
+ appname subcommand < tab> # autocompletes options for subcommand (phint init <tab>)
534
+ ```
535
+
492
536
### Related
493
537
494
538
- [ adhocore/phalcon-ext] ( https://github.com/adhocore/phalcon-ext ) Phalcon extension using ` adhocore/cli `
0 commit comments