mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
Phase 2 of the god-file decomposition plan. main()'s argparse tree is 179 inline add_parser calls in one 3,297-line function. This establishes the hermes_cli/subcommands/ package and extracts the first group (cron) as the proof-of-pattern: - hermes_cli/subcommands/_shared.py: shared parser helpers (add_accept_hooks_flag), re-exported from main.py for backwards compat. - hermes_cli/subcommands/cron.py: build_cron_parser(subparsers, cmd_cron=...). Handler injected so the module never imports main (cycle avoidance). - main()'s ~155-line inline cron block becomes one build_cron_parser() call. Behavior-neutral: 'hermes cron create --help' output is byte-identical to origin/main. main() 3297 -> 3143 LOC. Validation: tests/hermes_cli/ 6466 passed / 0 failed under per-file process isolation; new test_subcommands_cron.py covers subactions, aliases, options, no-agent tristate, injected dispatch, and --accept-hooks.
18 lines
786 B
Python
18 lines
786 B
Python
"""CLI subcommand parser builders for ``hermes <subcommand>``.
|
|
|
|
``hermes_cli/main.py:main()`` historically built the entire argparse tree
|
|
inline — 179 ``add_parser`` calls across ~26 subcommand groups, all wedged
|
|
into one 3,300-line function. This package breaks that tree apart: each
|
|
subcommand group owns a ``build_<group>_parser(subparsers, ...)`` function in
|
|
its own module, and ``main()`` calls those builders instead of inlining the
|
|
argument definitions.
|
|
|
|
Handlers (the ``cmd_*`` functions) still live in ``main.py`` for now and are
|
|
dependency-injected into the builders so these modules never import ``main``
|
|
(which would create a cycle). Shared parser helpers live in
|
|
``_shared.py``.
|
|
|
|
Part of the god-file decomposition plan (Phase 2).
|
|
"""
|
|
|
|
from __future__ import annotations
|