Skip to content

Conversation

@yeoldegrove
Copy link

Add Plugin Discovery and Integration

This PR adds comprehensive plugin discovery and integration functionality to nilla-cli, making it easy for users to discover and use plugins like nilla-home and nilla-nixos.
This solves the issue #22.

Features

Plugin Discovery

  • Automatically discovers nilla-* executables in the system PATH
  • Caches plugin metadata (version, usage, commands, examples) to avoid redundant process calls

Plugin Listing

  • New nilla plugins list command displays all available plugins in a formatted table
  • Shows plugin name, path, version, completion support, and available commands

Help Integration

  • Plugin information is automatically included in nilla --help output
  • Displays usage, commands, and examples for each discovered plugin
  • nilla <plugin> --help correctly shows the plugin's help instead of nilla's help
Usage: nilla [OPTIONS] [COMMAND]

[...]

Available Plugins
  home
    Usage: nilla home [OPTIONS] [COMMAND]
    Commands: switch, build, completions, help

  nixos
    Usage: nilla nixos [OPTIONS] [COMMAND]
    Commands: switch, test, build, completions, help

  Use `nilla plugins list` to see all plugins with details.
  Use `nilla <plugin> --help` to see plugin-specific help.

Shell Completions

  • Plugins appear as top-level commands in shell completions (e.g., nilla <TAB> home <TAB>)
  • Plugin commands are included in completions (e.g., nilla home switch <TAB>)
  • Completions are generated by nilla-cli itself, ensuring consistent behavior across shells
nilla <TAB>
build        -- Build a package from a Nilla project
completions  -- Generate autocompletions for your shell
help         -- Print this message or the help of the given subcommand(s)
home         -- Plugin: /nix/store/465il15cv5x9bldi5pm0vnnj003b56p7-nilla-home-0.0.0/bin/nilla-home
nixos        -- Plugin: /nix/store/1nc4fk1x7inv8h4vzv167wvbdv5szyv2-nilla-nixos-0.0.0/bin/nilla-nixos
plugins      -- Manage and list available plugins
run          -- Run a package's main program
shell        -- Start a development shell from a Nilla project
show         -- Show information about a Nilla project
nilla nixos <TAB>
build              -- Build a NixOS system
completions        -- Generate autocompletions for your shell
help               -- Print this message or the help of the given subcommand(s)
switch             -- Build, install, and switch into a system
test               -- Test a system

Technical Details

  • Plugin metadata is extracted by parsing --help and --version output
  • Metadata parsing focuses on robust sections: "Usage:", "Commands:", and "Examples:"
  • Plugin commands are dynamically added to the completion structure
  • Help output transforms plugin usage from nilla-<plugin> to nilla <plugin> format

- Add plugin discovery utility to search PATH for nilla-* executables
- Add 'nilla plugins list' command to show available plugins with metadata
- Integrate plugins into shell completions
- Add plugin information to help output
- Support plugin-specific completion integration
@yeoldegrove yeoldegrove force-pushed the feat/plugin-discovery branch from 0be13f1 to 39338c8 Compare January 8, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant