Architecture

Toast-cli follows a plugin-based architecture that makes it easy to extend and maintain.

Toast-cli Plugin Architecture (각 항목을 드래그하여 이동 가능)

Package Structure

toast-cli/
  ├── setup.py            # Package setup script
  ├── setup.cfg           # Package configuration
  ├── pyproject.toml      # Build system requirements
  ├── MANIFEST.in         # Additional files to include
  ├── VERSION             # Version information (v3.2.0.dev0)
  ├── README.md           # Project documentation
  ├── ARCHITECTURE.md     # Architecture documentation
  ├── LICENSE             # License information
  ├── docs/               # Documentation website files
  │   ├── CNAME           # Custom domain configuration
  │   ├── favicon.ico     # Website favicon
  │   ├── index.html      # Main documentation page
  │   ├── css/            # Stylesheet files
  │   ├── images/         # Documentation images
  │   └── js/             # JavaScript files
  └── toast/              # Main package
      ├── __init__.py     # Package initialization and CLI entry point
      ├── __main__.py     # Entry point for running as a module
      ├── helpers.py      # Helper functions and custom UI elements
      └── plugins/        # Plugin modules
          ├── __init__.py
          ├── base_plugin.py
          ├── am_plugin.py
          ├── cdw_plugin.py
          ├── ctx_plugin.py
          ├── dot_plugin.py
          ├── env_plugin.py
          ├── git_plugin.py
          ├── region_plugin.py
          └── utils.py

Adding New Plugins

To add a new plugin:

  1. Create a new Python file in the toast/plugins directory
  2. Define a class that extends BasePlugin
  3. Implement the required methods (execute and optionally get_arguments)
  4. Set the name and help class variables

The plugin will be automatically discovered and loaded when the application starts.

from toast.plugins.base_plugin import BasePlugin
import click

class MyPlugin(BasePlugin):
    name = "mycommand"
    help = "Description of my command"

    @classmethod
    def get_arguments(cls, func):
        # Optional: Define command arguments
        func = click.option("--option", "-o", help="An option for my command")(func)
        return func

    @classmethod
    def execute(cls, **kwargs):
        # Command implementation
        option = kwargs.get("option")
        if option:
            click.echo(f"Executing with option: {option}")
        else:
            click.echo("My custom command execution")

Benefits of the Plugin Architecture

  • Modularity: Each command is isolated in its own module
  • Extensibility: New commands can be added without modifying existing code
  • Maintainability: Code is organized into logical components
  • Testability: Plugins can be tested independently
  • Consistency: Common patterns are enforced through the base class
  • Discoverability: Commands are automatically found and registered