refactor(cli): use the canonical dispatch pattern for alerts and license#1056
Open
joshrotenberg wants to merge 1 commit into
Open
refactor(cli): use the canonical dispatch pattern for alerts and license#1056joshrotenberg wants to merge 1 commit into
joshrotenberg wants to merge 1 commit into
Conversation
The alerts, license and license workflow command groups were the last
enterprise commands using an in-file `enum + impl X { execute(&Config) }`
dispatch. Every other group (database, cluster, node, crdb, logs, module,
rbac) declares its enum separately and dispatches through a
`handle_x_command(conn_mgr, ...)` free function backed by a `*_impl.rs`
module.
Convert the three outliers to that shape:
- move `AlertsCommands`, `LicenseCommands` and `LicenseWorkflowCommands`
into cli/enterprise.rs as `EnterpriseAlertsCommands`,
`EnterpriseLicenseCommands` and `EnterpriseLicenseWorkflowCommands`
- add alerts_impl.rs, license_impl.rs and license_workflow_impl.rs
holding the handler functions
- take `&ConnectionManager` instead of building one from `&Config`, so
the workflow handlers read profiles off `conn_mgr.config`
- drop the cross-file `super::license::calculate_days_remaining` reach
from the workflow handlers in favour of a `super::license_impl` import
No behavior change: the clap attributes, subcommand names, aliases and
help text all move verbatim, and the handler bodies are unchanged.
Part of #1049.
joshrotenberg
marked this pull request as ready for review
July 25, 2026 20:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1049 (Phase 3, CODE-09).
Problem
alerts,licenseandworkflow licensewere the last enterprise command groups using an in-file dispatch pattern:Every other group (
database,cluster,node,crdb,logs,module,rbac) uses:with the enum declared separately and the handler bodies in a
*_impl.rsmodule.Change
cli/enterprise.rsasEnterpriseAlertsCommands,EnterpriseLicenseCommandsandEnterpriseLicenseWorkflowCommands, matching theEnterprise*Commandsnaming of its neighbours.alerts_impl.rs,license_impl.rsandlicense_workflow_impl.rsholding the handler functions.alerts.rs,license.rsandlicense_workflow.rsare now dispatch-only, exposinghandle_alerts_command,handle_license_commandandhandle_license_workflow_command.&ConnectionManagerrather than constructing one from&Config. The workflow handlers, which need the profile list, read it offconn_mgr.config.license_workflow_impl.rsimportscalculate_days_remainingandbytes_to_gbfromlicense_implinstead of reaching intosuper::licensefrom a sibling command module.Behavior
None intended. The clap attributes, subcommand names, aliases,
after_helpexamples and handler bodies all move verbatim.enterprise alerts --help,enterprise license --helpandenterprise workflow license --helprender the same command lists as before.Two things were deliberately left alone:
handle_enterprise_workflow_commandstill passesNoneforqueryto the license workflow (main.rs). That drops the global--query/-qforenterprise workflow license, but it is pre-existing and orthogonal to the dispatch shape.license_workflow_impl::license_monitorstill callsstd::process::exit(1)for--fail-on-warning. That belongs with the exit-code taxonomy work in Automation contract: tracing corrupts -o json, duplicate error line, exit codes, error envelope #1045.Checks
cargo fmt --all -- --check,cargo clippy --all-targets -- -D warningsandcargo testall pass locally.cargo doc --no-deps --all-featuresproduces only the two pre-existing warnings incli/enterprise.rs(module:argsand a bare cluster URL), unchanged by this diff.Follow-up
The "add a command" checklist for AGENTS.md, also listed under #1049 Phase 3, is a separate docs-only change and is not in this PR.