bamarni / symfony-console-autocomplete Goto Github PK
View Code? Open in Web Editor NEWShell autocompletion for Symfony Console based scripts
License: Other
Shell autocompletion for Symfony Console based scripts
License: Other
Currently, there is no tag made, which means that when including the package via composer the dev-master
version must be used.
Could you please tag a release to make it easier for composer users?
The tests in tests/*.bats
don't test for the correctness or usability of the shell code generated.
All of the tests merely compare the output against a cached copy of what it assumes the output should be.
This leads to inflexible tests, and more effort to make trivial changes.
An example of a better test methodology might be:
It is a little concerning that the test that failed depends on a byte-for-byte comparison against a copy of the code it tests.
I recall an article I read a long time ago about a dev who built a unit test that contained an exact copy of the code being tested, a particularly tricky algorithm. The dev said they were okay with updating it twice (once in the source and once in the unit test) stating it was worth 100% code coverage.
Reasons not to do this:
1. It doesn't actually test the code for correctness.
Since it's just a simple text diff, it doesn't matter how the code works, just that it's the same.
Furthermore, if there's a bug in both the source and the copy, the test won't show it - in fact, it'll pass! Instead of testing for the presence of bugs, this test actually presents a barrier to fixing the bug since it must now be fixed in multiple places.
(I'm sure there are other tests that test for correctness, but my point is that this one doesn't.)
2. It deliberately violates DRY (Don't Repeat Yourself).
The code has to exist in two places, and must be updated in both places.
I suppose this could be fixed by copying the source file into the cache before starting, but that IMO would be equally silly.
3. It's extra development overhead.
It's an extra step to making changes, and can be confusing to new developers (it confused me).
It can also muddy the intent of commits in the git history; it may be harder to grok the change intended by the dev, if the change is made n times instead of just one. It's the same reason I avoid committing auto-generated files alongside the files they were generated from - just having one source of truth is best.
Originally posted by @h3xx in #73 (comment)
Currently for a non-symfony based tool :
> phpunit [TAB]
PHPUnit -- 5.0.10 by Sebastian Bergmann and contributors.
unrecognized -- option --no-ansi
This could also happen in a Symfony application if it's in a broken state (eg. fatal error during development). For those cases it should not try to autocomplete anything, there could be something similar to the bash completion check (https://github.com/bamarni/symfony-console-autocomplete/blob/master/templates/default.bash.tpl#L37).
Hello, i am getting this error with PHP 8.1 it could be possible that a new version of symfony/console
is needed?
At least to what i understood from here: symfony/symfony#42260
bash: /etc/bash_completion.d/composer: line 2: syntax error near unexpected token
('
bash: /etc/bash_completion.d/composer: line 2: Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /tmp/symfony-console-autocomplete-master/vendor/symfony/console/Helper/HelperSet.php on line 112'
Thank you!
maybe its colliding with some other auto complete scripts I have for git etc?
This tool does not work oob, error:
user@bionic:~/tmp/symfony$ symfony-autocomplete composer
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Process\Process::__construct() must be of the type array, string given, called in /home/user/.config/composer/vendor/bamarni/symfony-console-autocomplete/src/DumpCommand.php on line 76 and defined in /home/user/.config/composer/vendor/symfony/process/Process.php:140
Stack trace:
#0 /home/user/.config/composer/vendor/bamarni/symfony-console-autocomplete/src/DumpCommand.php(76): Symfony\Component\Process\Process->__construct('composer list ...')
#1 /home/user/.config/composer/vendor/symfony/console/Command/Command.php(255): Bamarni\Symfony\Console\Autocomplete\DumpCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /home/user/.config/composer/vendor/symfony/console/Application.php(925): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/user/.config/composer/vendor/symfony/c in /home/user/.config/composer/vendor/symfony/process/Process.php on line 140
user@bionic:~/tmp/symfony$ php --version
PHP 7.3.15-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 23 2020 07:23:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.15, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.15-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Currently, the autocomplete generator runs my app over 60 times (once for the list of commands, and then once per command).
Capturing what is actually run ...
Array
(
[0] => ./wu list --raw | awk '{if (NF>1) print $1 " " substr($0, index($0,$2)); else print $1}'
[1] => ./wu help --format=xml bulk-redeem
[2] => ./wu help --format=xml capture-mobi
[3] => ./wu help --format=xml dump-session
[4] => ./wu help --format=xml generate-offer-codes
[5] => ./wu help --format=xml help
[6] => ./wu help --format=xml list
[7] => ./wu help --format=xml protect-migrations
[8] => ./wu help --format=xml reset-migrations
[9] => ./wu help --format=xml update-hosts
[10] => ./wu help --format=xml code:verify-subscriber-signatures
...
But all that data is available via 1 command:
./wu --xml list
Here's an edited snippet of the output (matching the list of calls above) ...
<?xml version="1.0" encoding="UTF-8"?>
<symfony name="Workflow Utilities" version="Enchilada">
<commands>
<command id="bulk-redeem" name="bulk-redeem">
<usages>
<usage>bulk-redeem [--salesStart [SALESSTART]] [--salesEnd [SALESEND]] [--effectiveRedemptionDate [EFFECTIVEREDEMPTIONDATE]] [--unredeem] [--dry-run] [--] <companyID></usage>
</usages>
<description>Bulk redeem items, based on certain criteria <fire>[ Development Only ]</fire></description>
<help>This will fully redeem orders based on criteria supplied on the command line.
A daily log will be produced in <fg=yellow>/Users/richardquadling/dt/app/logs/Development/BulkRedeem/</fg=yellow>.
</help>
<arguments>
<argument name="companyID" is_required="1" is_array="0">
<description>Required companyID</description>
<defaults/>
</argument>
</arguments>
<options>
<option name="--salesStart" shortcut="" accept_value="1" is_value_required="0" is_multiple="0">
<description>Only include items sold since this date-time (eg. "2016-10-09 09:00:00")</description>
<defaults/>
</option>
<option name="--salesEnd" shortcut="" accept_value="1" is_value_required="0" is_multiple="0">
<description>Only include items sold up until this date-time (eg. "2016-10-10 23:59:59")</description>
<defaults/>
</option>
<option name="--effectiveRedemptionDate" shortcut="" accept_value="1" is_value_required="0" is_multiple="0">
<description>The redemption date-time to use (eg. "2016-01-01 00:00:00"). Defaults to "now".</description>
<defaults/>
</option>
<option name="--unredeem" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Un-redeem the matching items</description>
</option>
<option name="--dry-run" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Dry run - do not make any changes</description>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="capture-mobi" name="capture-mobi">
<usages>
<usage>capture-mobi [-i|--ip-address IP-ADDRESS] [-u|--username USERNAME] [-p|--password PASSWORD] [--enable] [--disable]</usage>
</usages>
<description>Tell the router to redirect the .MOBI domain to this machine <fire>[ Development Only ]</fire></description>
<help>The .MOBI domain is directed to the public IP address of the router.
This program will tell the router to redirect requests, both HTTP and HTTPS, to this machine
Optionally, it can be told to redirect to another machine.</help>
<arguments/>
<options>
<option name="--ip-address" shortcut="-i" accept_value="1" is_value_required="1" is_multiple="0">
<description>Use this IP address</description>
<defaults>
<default>xxxxxxxx</default>
</defaults>
</option>
<option name="--username" shortcut="-u" accept_value="1" is_value_required="1" is_multiple="0">
<description>Router username</description>
<defaults>
<default>xxxxxxxxxx</default>
</defaults>
</option>
<option name="--password" shortcut="-p" accept_value="1" is_value_required="1" is_multiple="0">
<description>Router password</description>
<defaults>
<default>xxxxxxxxxx</default>
</defaults>
</option>
<option name="--enable" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Enable NAT redirection for the .MOBI domain to this machine.</description>
</option>
<option name="--disable" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable NAT redirection for the .MOBI domain to this machine.</description>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="dump-session" name="dump-session">
<usages>
<usage>dump-session [-w|--watch] [--] <session></usage>
</usages>
<description>Dump session <fire>[ Personal Only ]</fire></description>
<help>Dump session <fire>[ Personal Only ]</fire></help>
<arguments>
<argument name="session" is_required="1" is_array="0">
<description>Session filename in <file>~/dt/data/sessions</file>.</description>
<defaults/>
</argument>
</arguments>
<options>
<option name="--watch" shortcut="-w" accept_value="0" is_value_required="0" is_multiple="0">
<description>Watch for changes to the file</description>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="generate-offer-codes" name="generate-offer-codes">
<usages>
<usage>generate-offer-codes [-s|--save] [-e|--environment ENVIRONMENT] [--] <offerID> <qty></usage>
</usages>
<description>Generate a number of unique codes for an offer <fire>[ Development Only ]</fire></description>
<help>Generate a number of unique codes for an offer <fire>[ Development Only ]</fire></help>
<arguments>
<argument name="offerID" is_required="1" is_array="0">
<description>The ID of the offer for which you want to generate coupon codes</description>
<defaults/>
</argument>
<argument name="qty" is_required="1" is_array="0">
<description>The number of coupon codes you wish to generate</description>
<defaults/>
</argument>
</arguments>
<options>
<option name="--save" shortcut="-s" accept_value="0" is_value_required="0" is_multiple="0">
<description>Whether to actually persist the generated code to the database</description>
</option>
<option name="--environment" shortcut="-e" accept_value="1" is_value_required="1" is_multiple="0">
<description>The system you wish to generate offer codes in (development, staging, etc)</description>
<defaults>
<default>development</default>
</defaults>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="help" name="help">
<usages>
<usage>help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]</usage>
</usages>
<description>Displays help for a command</description>
<help>The <info>help</info> command displays help for a given command:
<info>php ./wu help list</info>
You can also output the help in other formats by using the <comment>--format</comment> option:
<info>php ./wu help --format=xml list</info>
To display the list of available commands, please use the <info>list</info> command.</help>
<arguments>
<argument name="command_name" is_required="0" is_array="0">
<description>The command name</description>
<defaults>
<default>help</default>
</defaults>
</argument>
</arguments>
<options>
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>To output help as XML</description>
</option>
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0">
<description>The output format (txt, xml, json, or md)</description>
<defaults>
<default>txt</default>
</defaults>
</option>
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>To output raw command help</description>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="list" name="list">
<usages>
<usage>list [--xml] [--raw] [--format FORMAT] [--] [<namespace>]</usage>
</usages>
<description>Lists commands</description>
<help>The <info>list</info> command lists all commands:
<info>php ./wu list</info>
You can also display the commands for a specific namespace:
<info>php ./wu list test</info>
You can also output the information in other formats by using the <comment>--format</comment> option:
<info>php ./wu list --format=xml</info>
It's also possible to get raw list of commands (useful for embedding command runner):
<info>php ./wu list --raw</info></help>
<arguments>
<argument name="namespace" is_required="0" is_array="0">
<description>The namespace name</description>
<defaults/>
</argument>
</arguments>
<options>
<option name="--xml" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>To output list as XML</description>
</option>
<option name="--raw" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>To output raw command list</description>
</option>
<option name="--format" shortcut="" accept_value="1" is_value_required="1" is_multiple="0">
<description>The output format (txt, xml, json, or md)</description>
<defaults>
<default>txt</default>
</defaults>
</option>
</options>
</command>
<command id="protect-migrations" name="protect-migrations">
<usages>
<usage>protect-migrations [-r|--rename] [--force] [-d|--down-only]</usage>
</usages>
<description>Rename local migrations that have not been deployed so that they are at the head of the queue. <fire>[ Development Only ]</fire></description>
<help>The purpose of this script is to examine any migrations that have not been run on the production
environment and to move them so that no rollback is performed on the production environment.
For example, if a 2 independent feature branches are developed, each with their own migrations, are
feature finished and released at different times, the second branch's migrations will appear as "down"
within the live migrations.
When these are migrated, phinx will rollback the new migrations necessary to run all of the migrations
in order.
This will almost certainly result in data loss.
So this script is an attempt to prevent that from happening.
The steps taken are as follows:
1 - Identify all the migrations in the codebase.
2 - Identify all the migrations in the production environment.
3 - Analyse the dates to make sure that all of the outstanding migrations will not cause any rollback in
the production environment.
4 - Optionally, renumber all the outstanding migrations, preserving their order, so that they all occur
after the most recent production migration.
Ideally, this needs to be done just before branch is merged and deployed and run for one branch at a time</help>
<arguments/>
<options>
<option name="--rename" shortcut="-r" accept_value="0" is_value_required="0" is_multiple="0">
<description>Rename the migration SQL scripts.</description>
</option>
<option name="--force" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force a rename even if migrations are correctly positioned.</description>
</option>
<option name="--down-only" shortcut="-d" accept_value="0" is_value_required="0" is_multiple="0">
<description>Only rename migrations that are down locally.</description>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="reset-migrations" name="reset-migrations">
<usages>
<usage>reset-migrations [--reset-migrations] [-m|--mysqldump-path MYSQLDUMP-PATH] [-e|--environment ENVIRONMENT]</usage>
</usages>
<description>Remove all migrations and rebuild the initial data structure and seed data SQL files. <fire>[ Development Only ]</fire></description>
<help>The purpose of this script is to remove all migrations and rebuild the initial data structure and the seed data SQL files.</help>
<arguments/>
<options>
<option name="--reset-migrations" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Reset phinx and remove the migrations. Without this option, only the initial schema and seed data SQL files will be built.</description>
</option>
<option name="--mysqldump-path" shortcut="-m" accept_value="1" is_value_required="1" is_multiple="0">
<description>Alternative path to mysqldump utility</description>
<defaults/>
</option>
<option name="--environment" shortcut="-e" accept_value="1" is_value_required="1" is_multiple="0">
<description>The target environment</description>
<defaults>
<default>development</default>
</defaults>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="update-hosts" name="update-hosts">
<usages>
<usage>update-hosts [-s|--specific-ip SPECIFIC-IP] [--] [<hosts>]</usage>
</usages>
<description>Add all DigiTickets sub-domains to your local hosts file <fire>[ Development Only ]</fire></description>
<help>This program will add all the sub-domains from the digitickets.companies database to your local hosts file.</help>
<arguments>
<argument name="hosts" is_required="0" is_array="0">
<description>The full filename of your hosts file</description>
<defaults>
<default>/etc/hosts</default>
</defaults>
</argument>
</arguments>
<options>
<option name="--specific-ip" shortcut="-s" accept_value="1" is_value_required="1" is_multiple="0">
<description>The specific IP address to use for the sub-domains</description>
<defaults>
<default>127.0.0.1</default>
</defaults>
</option>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
<command id="code:verify-subscriber-signatures" name="code:verify-subscriber-signatures">
<usages>
<usage>code:verify-subscriber-signatures</usage>
</usages>
<description>Verify that the signatures of the PHPMaker CMS Subscribers are correctly following our pattern <fire>[ Development and Staging Only ]</fire></description>
<help>Verify that the signatures of the PHPMaker CMS Subscribers are correctly following our pattern.
This will alert you to any naming collisions that previously existed</help>
<arguments/>
<options>
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this help message</description>
</option>
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not output any message</description>
</option>
<option name="--verbose" shortcut="-v" shortcuts="-v|-vv|-vvv" accept_value="0" is_value_required="0" is_multiple="0">
<description>Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</description>
</option>
<option name="--version" shortcut="-V" accept_value="0" is_value_required="0" is_multiple="0">
<description>Display this application version</description>
</option>
<option name="--ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Force ANSI output</description>
</option>
<option name="--no-ansi" shortcut="" accept_value="0" is_value_required="0" is_multiple="0">
<description>Disable ANSI output</description>
</option>
<option name="--no-interaction" shortcut="-n" accept_value="0" is_value_required="0" is_multiple="0">
<description>Do not ask any interactive question</description>
</option>
</options>
</command>
</commands>
<namespaces>
<namespace id="_global">
<command>bulk-redeem</command>
<command>capture-mobi</command>
<command>dump-session</command>
<command>generate-offer-codes</command>
<command>help</command>
<command>list</command>
<command>protect-migrations</command>
<command>reset-migrations</command>
<command>update-hosts</command>
</namespace>
<namespace id="code">
<command>code:verify-subscriber-signatures</command>
</namespace>
</namespaces>
</symfony>
The only minor difference is that the descriptions are still with their styling. (e.g. <fire>[ DEVELOPMENT ONLY ]</fire>
)
But (at least for bash), the descriptions aren't used anywhere in $(brew --prefix)/etc/bash_completion.d/wu
, so maybe that's a non-issue.
If this is also true for the other shells, then calling the application once rather than n+1 times results in a nicer experience and means keeping the autocomplete uptodate isn't as long as it currently is.
I get the error:
Incorrect usage: flag provided but not defined: -format
Which I guess means that the command removed the --format option.
after installing this tool via
sudo composer global require bamarni/symfony-console-autocomplete
I get a "command not found error" after invoking symfony-autocomplete
on the bash.
I did a ssh relogin after installation completed successfully.
$ php -v
PHP 5.5.30-1+deb.sury.org~precise+1 (cli) (built: Oct 4 2015 16:14:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with blackfire v1.8.0, https://blackfire.io, by Blackfireio Inc.
composer
is updated to the latest version as of today.
any hints?
I'd like to be able to set the shell path completion from a certain directory. Is this already possible, or can this be implemented?
Example:
current working dir: /var/www/someapp
complete from: /var/www/someapp/somedir
so that you can have completion for example on file /var/www/someapp/somedir/somefile.php
Does the static setup work for ZSH or is it bash-only ? Looking at the code, it looks like it is not yet implemented, but the readme does not explain it.
We've got a problem using symfony-autocomplete
in cygwin , the problem was Symfony Process cannot find and run in path our Symfony based script because under windows Symfony Process can only run .exe
or .bat
( also bypass_shell = true ) which cannot run shebanged bash-style scripts ( we are not in a bash env ) and many custom script base con Symfony command are not executable in windows, they need to be run with their right interpreter
Composer is usually deployed on windows like a composer.bat
which can be found in path and ran, a workaround could be supply a symfony-autocomplete
cli option to run script like a php script
new Process(['php','<script>'],...
Hey,
After installing globally using:
composer global require bamarni/symfony-console-autocomplete
I keep getting the following error, even after restarting my terminal:
symfony-autocomplete: command not found
Any advice?
It'd be great if this was a default command in symfony so I could do (e.g.) bin/console complete
- could this code be reused inside the main package?
PHP Fatal error: Declaration of Application::getDefinition() must be compatible with Symfony\Component\Console\Application::getDefinition(): Symfony\Component\Console\Input\InputDefinition in /root/.composer/vendor/bamarni/symfony-console-autocomplete/bin/symfony-autocomplete on line 39
PHP Fatal error: Declaration of Application::getCommandName(Symfony\Component\Console\Input\InputInterface $input) must be compatible with Symfony\Component\Console\Application::getCommandName(Symfony\Component\Console\Input\InputInterface $input): ?string in /root/.composer/vendor/bamarni/symfony-console-autocomplete/bin/symfony-autocomplete on line 27
PHP Fatal error: Declaration of Application::getDefaultCommands() must be compatible with Symfony\Component\Console\Application::getDefaultCommands(): array in /root/.composer/vendor/bamarni/symfony-console-autocomplete/bin/symfony-autocomplete on line 32
Symfony 6 adds quite lots of type hinting which changes function signatures, so this won't magically make it support Symfony 6.
Any chance of getting support for http://fishshell.com/ ?
Hello,
For composer it works but how to make it work with symfony commands like cache:clear?
I do
php app/console ca[TAB] but nothing happens.
Any tips please?
Thanks
Counter to #11, I'm not getting bin/console to work at all with symfony-console-autocomplete.
On Ubuntu 18.08, I've done the following:
composer global require bamarni/symfony-console-autocomplete
adding eval $(symfony-autocomplete)
in ~/.bashrc causes a syntax error.
symfony-autocomplete composer | sudo tee /etc/bash_completion.d/composer
almost works; turns out that since /usr/share/bash_autocomplete/ is installed, it's the only one that's recognized by complete.
symfony-autocomplete composer | sudo tee /usr/share/bash-completion/completions/composer
is actually read and used.
At this point, on starting up a shell, composer autocompletes. But bin/console (from a Symfony project directory) only "globs"; the autocompletion stuff does not get invoked at all.
I'm not sure what diagnostics you need, but running complete -p
....
vagrant@homestead:/usr/share/bash-completion/completions$ complete -p composer
complete -o default -F _composer composer
vagrant@homestead:/usr/share/bash-completion/completions$ complete -p console
-bash: complete: console: no completion specification
vagrant@homestead:/usr/share/bash-completion/completions$ complete -p bin/console
complete -F _minimal bin/console
What more do I have to do in order to get this to work?
the readme tells us how to install this tool, but there is no help on how to update it.
I installed it some time ago and you already did some further progress on it, but I dont know how to update my installation.
I tried things like symfony-autocomplete self-update
which I am used to by composer itself etc, but nothing worked yet.
Normally I would consider this an inconsiderate edge-case not worth complaining about, but considering the big deal that composer makes about running it with xdebug enabled, I thought someone might have a good idea for how to get this to work with aliases of aliases?
I have a custom php.ini that I load with composer:
alias c='php -c /home/jeff/php/composer.php.ini /usr/local/bin/composer'
So unfortunately, the aliases
option doesn't fly in this situation:
symfony-autocomplete --aliases=c
Direct aliases work great:
alias comp='composer'
eval "$(symfony-autocomplete --aliases=comp)"
But then I end up with the foul performance warning:
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
I need xdebug enabled in my default php cli because I rely on it with too many other tools.
Hi.
I have a Symfony console based application that will take a git branch and does a bunch of analysis between the chosen branch and several other branches.
The code all works fine.
What I'd like to do is have git's branch autocomplete logic as part of this applications autocomplete.
So, taking wu
as the utility, code:analysis
as the command to run, and RAQ-123
is the beginning of the branch name (Jira naming), we end up with wu code:analysis RAQ-123-[TAB][TAB]
.
It is at this stage that I want git's autocompletion to kick in and return the complete branch name for the utility.
Of course there are 2 issues here.
First identifying the particular parameter is a git branch for the autocompletion (I'd go with having something specifically looked for in the description of the argument or option), and secondly incorporating the autocomplete from another program (no idea).
Any suggestions, recommendations, further reading, worked example (woo hoo) would be great.
Hello,
I tried symfony-console-autocomplete yesterday, and i was very happy with it, autocompletion was working perfectly, but this morning i couldn't login because of an error in my session.
Here is the message:
/etc/mdm/Xsession: 6: eval: Syntax error: "(" unexpected (expecting "}")
In console mode i add to delete the eval "$(symfony-autocomplete)"
line from my ~/.profile so i could login in graphic mode.
So I tried the other method instead of the "eval":
symfony-autocomplete composer | tee ~/.symfony-autocomplete
And then add to my ~/.profile
if [ -f "$HOME/.symfony-autocomplete" ] ; then
. "$HOME/.symfony-autocomplete"
fi
But i got the same Syntax error on line 6 when i tried to login, plus autocompletion wasn't working anymore
Did i go wrong somewhere ? Thanks ^^
(Oh and i'm on Linux Mint 17.3)
I'd like to enable autocompletion for Acquia CLI, which is a Symfony Console app. On my local setup, autocompletion works for other Symfony Console apps (i.e. Composer) but not Acquia CLI. Is some specific action required to enable integration?
If I run symfony-autocomplete acli
it seems to dump the autocompletion file as expected, but simply running acli [TAB]
produces no results, while composer [TAB]
does.
The boilerplate in the bin-stub (bin/symfony-autocomplete
) hard-encodes the name of the vendor folder (Composer).
This binds it to the default value only ("vendor
") and is preventing any other configuration of COMPOSER_VENDOR_DIR
which is part of the standard Composer environment.
As this is a Composer package, it should support the standard configuration.
I'd like to suggest to cache working with commands.
This would be useful for heavy responded commands.
So, there are code blocks for both cases:
# completing for an option
# [...]
# cache output into a file
cache_file=/tmp/bash_completion_$(echo $opts | tr -d ' :/?!')
if [ ! -f ${cache_file} ]; then
$opts --no-ansi 2>/dev/null > ${cache_file}
fi
# completing for a command
# [...]
# cache output into a file
cache_file=/tmp/bash_completion_$(echo $script'-list' | tr -d ' :/?!')
if [ ! -f ${cache_file} ]; then
$script list --raw 2>/dev/null > ${cache_file}
fi
And command calling below should be replaced with getting content of a created file:
cat ${cache_file} | ...
Modified result of the command symfony-autocomplete
:
#!/bin/bash
_symfony()
{
local cur script com opts
COMPREPLY=()
_get_comp_words_by_ref -n : cur words
# for an alias, get the real script behind it
if [[ $(type -t ${words[0]}) == "alias" ]]; then
script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/")
else
script=${words[0]}
fi
# lookup for command
for word in ${words[@]:1}; do
if [[ $word != -* ]]; then
com=$word
break
fi
done
# completing for an option
if [[ ${cur} == --* ]] ; then
opts=$script
[[ -n $com ]] && opts=$opts" -h "$com
# cache output into a file
cache_file=/tmp/bash_completion_$(echo $opts | tr -d ' :/?!')
if [ ! -f ${cache_file} ]; then
$opts --no-ansi 2>/dev/null > ${cache_file}
fi
opts=$(cat ${cache_file} | sed -n '/Options/,/^$/p' | sed -e '1d;$d' | sed 's/[^--]*\(--.*\)/\1/' | sed -En 's/[^ ]*(-(-[[:alnum:]]+){1,}).*/\1/p' | awk '{$1=$1};1'; exit ${PIPESTATUS[0]});
[[ $? -eq 0 ]] || return 0;
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
__ltrim_colon_completions "$cur"
return 0
fi
# completing for a command
if [[ $cur == $com ]]; then
# cache output into a file
cache_file=/tmp/bash_completion_$(echo $script'-list' | tr -d ' :/?!')
if [ ! -f ${cache_file} ]; then
$script list --raw 2>/dev/null > ${cache_file}
fi
coms=$(cat ${cache_file} | awk '{print $1}'; exit ${PIPESTATUS[0]})
[[ $? -eq 0 ]] || return 0;
COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
__ltrim_colon_completions "$cur"
return 0;
fi
}
complete -o default -F _symfony console
complete -o default -F _symfony composer
complete -o default -F _symfony php-cs-fixer
complete -o default -F _symfony phpspec
complete -o default -F _symfony behat
# my custom one
complete -o default -F _symfony magento
Of course all cache can be dropped by deleting /tmp/bash_completion_*
.
I have successfully set this wonderful library up and it works for completions of composer
. However I use c
as an alias to composer
. And it doesn't work for the alias which is normal.
However I have g
aliased to git
and the completion for g
works by using:
complete -o default -o nospace -F _git g
https://github.com/hkdobrev/dotfiles/blob/b923c4128ba25197cce0afb085447e95b2aab4a1/.aliases#L34-L35
I've tried setting it up with:
complete -o default -o nospace -F _symfony c
But it doesn't work. Any suggestions on how to set this up?
I've installed this package globally and added $HOME/.composer/vendor/bin
to my PATH
. My ~/.profile
file looks now:
# set PATH so it includes composer's bin if it exists
if [ -d "$HOME/.composer/vendor/bin" ] ; then
PATH="$HOME/.composer/vendor/bin:$PATH"
fi
# see https://github.com/bamarni/symfony-console-autocomplete
eval "$(symfony-autocomplete)"
Then I've re-checked my PATH
by echo $PATH
and it looks properly.
Command symfony-autocomplete
is now available.
I have two projects that are using Symfony2 and Symfony3 and autocompletion doesn't works.
symfony-2$ app/console [TAB] # only lists me subdirectories
symfony-3$ bin/console [TAB] # only lists me subdirectories
Environment:
Ubuntu 16.04
$ composer --version
Composer version 1.1.2 2016-05-31 19:48:11
$ php --version
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Ran the following as per instructions on readme:
composer global require bamarni/symfony-console-autocomplete
symfony-autocomplete composer
symfony-autocomplete composer > $(brew --prefix)/etc/bash_completion.d/composer
Which then gave the error:
zsh: command not found: symfony-autocomplete
Dockerfile
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y \
openssl \
git \
unzip \
wget \
bash-completion
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer --version
# autocompleter
RUN composer global require bamarni/symfony-console-autocomplete \
&& echo 'export PATH="$PATH:~/.composer/vendor/bin/"' >> ~/.bashrc \
&& echo 'eval "$(symfony-autocomplete)"' >> ~/.bashrc
WORKDIR /var/www
bash_completion version:
# apt-cache policy bash-completion
bash-completion:
Installed: 1:2.8-6
Candidate: 1:2.8-6
Version table:
*** 1:2.8-6 500
500 http://deb.debian.org/debian buster/main amd64 Packages
100 /var/lib/dpkg/status
When try to use:
# composer bash: _get_comp_words_by_ref: command not found
html/bash: _get_comp_words_by_ref: command not found
bash: _get_comp_words_by_ref: command not found
bash: _get_comp_words_by_ref: command not found
Am i doing something wrong?
symfony-console-autocomplete/composer.json
Lines 8 to 9 in fa77f35
We run our software in docker and I think that might be interfering with the way symfony process starts the script to get the raw list of commands. I can dump the list no problem with docker-compose exec
, so it would be cool if I could just dump it into symfony-autocomplete and get the tab-complete script back out (as I do now, on stdout, which is awesome!)
The usage would be something like
my-non-obvious-way-to-execute-the-script | symfony-autocomplete.
Would you be interested in this? I might try to provide a PR, it shouldn't be difficult, just a test with istty
.
I've found that executing eval "$(symfony-autocomplete)"
either on the terminal or adding it to ~/.bash_profile
does not make autocompletion available.
However, running symfony-autocomplete > $(brew --prefix)/etc/bash_completion.d/symfony-autocomplete
and re-sourcing ~/.bash_profile
does work.
This seems a bit heavy-handed. Any idea why the eval
approach would fail?
I want to use this tool inside a php docker container.
I get the error "Notice: Undefined index SHELL in bamarni/symfony-console-autocomplete/symfony-autocomplete on line 68"
Is it possible to run or update the scripts to be able to run inside a docker container ?
Thanks.
We have an internal tool I'm trying to generate completions for, and some of the option strings include things like:
--opt "device where name=<customerid>-foo"
In this case, ZSH is unable to load the generated completions due to the <
being unescaped. Outputting to a file and giving a quick replace of all instances of <
with \<
allowed this to work.
The second problem case is where options contain single quotes in the usage description for example, an option:
--opt "a "string" to use"
causes the following ZSH error:
#> tool param:name:delete --
_tool.phar:181: bad set of key/value pairs for associative array
_tool.phar:181: bad set of key/value pairs for associative array
_tool.phar:181: bad set of key/value pairs for associative array
I believe the "'s also need escaped when the completions are rendered.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.