Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration file to specify which commands are available. #69

Merged
merged 2 commits into from
May 21, 2018

Conversation

bangpound
Copy link
Contributor

Many users will not have apc and apcu enabled on the same servers. Symfony Console's \Symfony\Component\Console\Application::find method will attempt to find commands that match partial names but this cannot work when there are commands whose namespaces are subsets of other commands.

For example, when all extensions are enabled, it's not possible to abbreviate most of the commands in either apc or apcu namespace:

$ ./bin/cachetool a:k:f some-key --no-ansi
                                                       
  Command "a:k:f" is ambiguous.                        
  Did you mean one of these?                           
      apc:key:fetch  Shows the content of an APC key   
      apcu:key:fetch Shows the content of an APCu key  
                                                       

When the config file specifies which extensions to support, calling commands with abbreviations is possible:

extensions: [opcache, apcu]
$ ./bin/cachetool a:k:f some-key
APCu key=some-key has value='thing'

To avoid breaking backward compatibility, \CacheTool\Console\Config::__construct now uses array_replace to provide defaults when config properties aren't set in the $config argument.

The command list in this tool is very large, and for many users,
APC and APCu will not be used at the same time.
If a configuration file does not define `extensions` then
all commands are available.
@Seldaek
Copy link

Seldaek commented Apr 3, 2018

How about just loading/enabling the commands conditionally depending on which extensions are loaded in the process? Then stuff that's useless would be hidden automatically.

@bangpound
Copy link
Contributor Author

@Seldaek I considered this, but the PHP executable that runs cachetool can be different from the PHP instance that it is connecting to. A cache extension that isn't available in /usr/bin/php might be the one I want to modify which is running on FPM on port 9000 mapped to localhost from a Docker container. Is that valid?

@Seldaek
Copy link

Seldaek commented May 1, 2018 via email

@gordalina gordalina merged commit 9ca4c9e into gordalina:master May 21, 2018
@gordalina
Copy link
Owner

Thanks for your contribution, its part of release 3.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants