`_prepend_subcommands` not honoured

#1976 · closed · 3 comments

View on GitHub ↗

madduck

### Description Specifying `_prepend_commands` in the configuration and then invoking the CLI without any actions results in an error "Missing command". ### Steps to reproduce 1. `pipx install tptools` 2. `mkdir ~/.config/tptools` 3. `echo -e '[tpsrv]\n_default_subcommands = ["debug"]' > ~/.config/tptools/cfg.toml` 4. Run `tpsrv -vvv`: ``` $ tpsrv -vvv 2026-09-27 14:03:32 click_extra.logging debug Set <Logger click_extra (DEBUG)> to DEBUG. (logging.py:647) 2026-09-27 14:03:32 click_extra.logging debug Set <RootLogger root (DEBUG)> to DEBUG. (logging.py:647) 2026-09-27 14:03:32 click_extra.logging debug Increased log verbosity by 3 levels: from WARNING to DEBUG. (logging.py:823) 2026-09-27 14:03:32 click_extra.config.option debug Load configuration matching /home/siby/.config/tptools/cfg.toml (option.py:1913) 2026-09-27 14:03:32 click_extra.config.option debug Search filesystem for /home/siby/.config/tptools/cfg.toml (option.py:1090) 2026-09-27 14:03:32 click_extra.config.option debug Found candidate: /home/siby/.config/tptools/cfg.toml (option.py:1113) 2026-09-27 14:03:32 click_extra.config.option debug Parsing /home/siby/.config/tptools/cfg.toml with TOML (option.py:1344) 2026-09-27 14:03:32 click_extra.config.option debug TOML parsing successful, got {'tpsrv': {'_default_subcommands': ['debug']}}. (option.py:1189) 2026-09-27 14:03:32 click_extra.config.option debug Parsed user configuration: {'tpsrv': {'_default_subcommands': ['debug']}} (option.py:1979) 2026-09-27 14:03:32 click_extra.config.option debug Initial defaults: None (option.py:1980) 2026-09-27 14:03:32 click_extra.config.option debug New defaults: ChainMap({}, {}) (option.py:2008) 2026-09-27 14:03:32 click_extra.logging debug Reset <RootLogger root (DEBUG)> to WARNING. (logging.py:531) 2026-09-27 14:03:32 click_extra.logging debug Reset <Logger click_extra (DEBUG)> to WARNING. (logging.py:531) Usage: tpsrv [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]... Try 'tpsrv --help' for help. Error: Missing command. ``` Compare that to: ``` $ tpsrv -vvv debug 2026-09-27 14:04:22 click_extra.logging debug Set <Logger click_extra (DEBUG)> to DEBUG. (logging.py:647) 2026-09-27 14:04:22 click_extra.logging debug Set <RootLogger root (DEBUG)> to DEBUG. (logging.py:647) 2026-09-27 14:04:22 click_extra.logging debug Increased log verbosity by 3 levels: from WARNING to DEBUG. (logging.py:823) 2026-09-27 14:04:22 click_extra.config.option debug Load configuration matching /home/siby/.config/tptools/cfg.toml (option.py:1913) 2026-09-27 14:04:22 click_extra.config.option debug Search filesystem for /home/siby/.config/tptools/cfg.toml (option.py:1090) 2026-09-27 14:04:22 click_extra.config.option debug Found candidate: /home/siby/.config/tptools/cfg.toml (option.py:1113) 2026-09-27 14:04:22 click_extra.config.option debug Parsing /home/siby/.config/tptools/cfg.toml with TOML (option.py:1344) 2026-09-27 14:04:22 click_extra.config.option debug TOML parsing successful, got {'tpsrv': {'_default_subcommands': ['debug']}}. (option.py:1189) 2026-09-27 14:04:22 click_extra.config.option debug Parsed user configuration: {'tpsrv': {'_default_subcommands': ['debug']}} (option.py:1979) 2026-09-27 14:04:22 click_extra.config.option debug Initial defaults: None (option.py:1980) 2026-09-27 14:04:22 click_extra.config.option debug New defaults: ChainMap({}, {}) (option.py:2008) 2026-09-27 14:04:22 click_async_plugins.util debug Setting up task for 'debug' (util.py:90) INFO: Started server process [6240] INFO: Waiting for application startup. 2026-09-27 14:04:22 click_async_plugins.util debug Scheduling task for 'debug' (util.py:51) 2026-09-27 14:04:22 click_async_plugins.debug debug Configuring stdin for raw input (debug.py:114) INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) ``` ### Version 9.3.4 ### Logs ```text ```

Comments

kdeldycke

Good catch! Thanks for the report. I can confirm this is an issue: you stumbled on this because your `PluginGroup` subclasses `click.Group` instead of `click_extra.Group`. So that should be the quick fix on your side. OTOH, I don't think there is a reason Click Extra to not work in this situation, so I will try to fix that issue directly and support that case.

kdeldycke

I just fixed the issue in the `main` branch of Click Extra. It will be part of a 9.3.5 release I'm going to cut in a couple of hours. In the mean time, feel free to test my fix in the development version to validate the fix.

madduck

Great. `click-async-plugins` doesn't depend on `click_extra` and doesn't need to, so great you are fixing this independently.