Writing your own plugins¶
Jira-select relies on setuptools entrypoints for determining what functions, commands, and formatters are available. This makes it easy to write your own as long as you’re familiar with python packaging, and if you’re not, you can also register functions at runtime.
Commands¶
To write your own commands, you need to:
Create a class that is a subclass of
jira_select.plugin.BaseCommand. This command:Must implement a
handlefunction.
Register that class via a setuptools entrypoint.
Your entrypoint should be in the
jira_select.commandssection.The name of your entrypoint will become the command’s name.
Functions¶
For functions, you have two choices:
You can create and install a user script into your user functions and within that script register a function using the method described in Direct Registration below.
If you plan to distribute your function on PyPI or would like for it to be installable generally, you can create an entrypoint; see Entrypoint below for details.
Direct Registration¶
Create a function in a python file somewhere.
Wrapping that function in
jira_select.plugin.register_function.Install that user script using the install-user-script command.
For example, if you have a file named my_user_function.py in your current directory with the following contents:
from jira_select.plugin import register_function
@register_function
def my_important_function(value):
"""Returns length of `value`
This function isn't doing anything useful, really, but
you could of course make it useful if you were to write
your own.
"""
return len(value)
you could install it with:
jira-select install-user-function my_user_function.py
and after that, you will have access to my_important_function in a query like:
select:
- my_important_function(key)
from: issues
Entrypoint¶
Create a class that is a subclass of
jira_select.plugin.Function. This command:Must implement a
__call__function.
Register that class via a setuptools entrypoint.
Your entrypoint should be in the
jira_select.functionssection.
Formatters¶
To write your own formatter, you need to:
Create a class that is a subclass of
jira_select.plugin.BaseFormatter. This command:Must implement a
writerowfunction.Must implement a
get_file_extensionclassmethod returning your format’s file extension.May implement an
openmethod for any setup functionality.May implement an
closemethod for any teardown functionality.
Register that class via a setuptools entrypoint.
Your entrypoint should be in the
jira_select.formatterssection.