fairyfly.cli package¶
Submodules¶
Module contents¶
Command Line Interface (CLI) entry point for fairyfly and fairyfly extensions.
Use this file only to add command related to fairyfly-core. For adding extra commands from each extension see below.
Note
Do not import this module in your code directly unless you are extending the command
line interface. For running the commands execute them from the command line or as a
subprocess (e.g. subprocess.call(['fairyfly', 'viz']))
Fairyfly is using click (https://click.palletsprojects.com/en/7.x/) for creating the CLI. You can extend the command line interface from inside each extension by following these steps:
Create a
cli.pyfile in your extension.Import the
mainfunction from thisfairyfly.cli.Add your commands and command groups to main using add_command method.
Add
import [your-extension].clito__init__.pyfile to the commands are added to the cli when the module is loaded.
The good practice is to group all your extension commands in a command group named after
the extension. This will make the commands organized under extension namespace. For
instance commands for fairyfly-therm will be called like
fairyfly therm [therm-command].
import click
from fairyfly.cli import main
@click.group()
def therm():
pass
# add commands to therm group
@therm.command('daylight-factor')
# ...
def daylight_factor():
pass
# finally add the newly created commands to fairyfly cli
main.add_command(therm)
# do not forget to import this module in __init__.py otherwise it will not be added
# to fairyfly commands.
Note
For extension with several commands you can use a folder structure instead
of a single file. Refer to fairyfly-therm for an example.