Plugins - Add 'basic-alias' and 'alias-cmd' to cv.phar #240
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Site aliases allow you to run a
cv
subcommand on a particular site without manually navigating through the filesystem. Compare:In the first example, it uses an alias (
@wombat
). The alias can define all these other options (path, URL, etc) so that you don't need to type them into every command.This functionality was previously demonstrated by implementing the
basic-alias
plugin that was published via gist, but this is fairly obscure. This PR addsbasic-alias
plugin as a built-in feature, and it also introduces a complementary plugin (alias-cmd
) for managing aliases via CLI.Before
You can manually construct commands with notes about bootstrap (re:
cd
,--cwd
,--user
,--url
, etc).You can download the alias plugin and create alias-files by hand.
After
There is a built-in alias-plugin and helper commands.
To define a new alias, run the
alias:add
command:This will ask questions about remote (SSH), multisite (base URL), default user-name, etc. It will ultimately create a file (such as
$HOME/.cv/alias/wpmaster.json
).Similarly, you can browse available aliases:
Finally, you can run commands with the alias, as in:
Comments
There's a sample build at https://think.hm/tmp/cv-aliases-2025-02-26-0.phar.
The general reason why
basic-alias
is a plugin is that it would be handy to make new variations on the functionality. There's a lot of subjectivity in what features should be provided for aliases. For example:civibuild
, then you might want to automatically recognize aliases for allBUILDKIT/build/*.sh
files.@staging
,@prod
), then you need to seek-out a context-sensitive config-file.In any case, the absence of a reference-implementation makes the whole thing seem esoteric.
With this approach, we can kind of have it both ways: