feat(plugins): Add plugin support
Description
Plugins allow users to extend the capabilities of the CLI. To build one, the plugin must adhere to the following:
- Must be prefixed with
glab-. - Must not conflict with the name of a built-in CLI command.
- Must be on the user's
$PATH. - Must be executable. A binary is not necessary - you can use a user script as well. This opens up the possibility for plugins to replace user aliases that are shell scripts.
In the spirit of an iterative and boring solution this commit adds
support for a binary plugin system in the style of git and kubectl.
If users would like to see official plugin registries, plugin
installation, management, etc. This solution can be built on top of.
Related Issues
Resolves #1053
How has this been tested?
I tested this manually using a basic glab-hello shell script. This can be
reproduced using the following steps.
- Add the following script to your "$PATH" e.g. save it as
/usr/local/bin/glab-helloon *nix machines with executable bits sets.
#!/usr/bin/env bash
echo "Hello $*!"
- Build and run the test plugin -
make && bin/glab hello Oscar.
❯ bin/glab hello Oscar
Hello Oscar!
Screenshots (if appropriate):
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms) -
Test gap
Edited by Oscar Tovar
