Skip to content

Add parser-level validity gate for generated next_commands#203

Merged
imaurer merged 1 commit intomainfrom
validate-next-commands
Mar 12, 2026
Merged

Add parser-level validity gate for generated next_commands#203
imaurer merged 1 commit intomainfrom
validate-next-commands

Conversation

@imaurer
Copy link
Collaborator

@imaurer imaurer commented Mar 12, 2026

Summary

  • Adds a #[cfg(test)] module next_commands_validity in src/cli/mod.rs that asserts each helper-generated next_commands entry parses successfully via Cli::try_parse_from
  • Covers all 11 entity surfaces: gene, variant, article, trial, disease, pgx, drug, pathway, protein, adverse-event, device-event
  • Exercises shell-quoted multi-word arguments, conditional variant oncokb template with ONCOKB_TOKEN-independent parsing, hyphenated pathway IDs, and optional subcommand args

Why

The _meta.next_commands field in JSON/spec responses is generated by helper functions and consumed directly by users and downstream tooling. Previously there was no automated check that these generated command strings actually parse against the CLI definition. This gate catches stale or malformed command suggestions before they ship.

Test plan

  • cargo test --lib cli::next_commands_validity — 11 tests pass
  • cargo test --lib — full unit suite remains green (595 passed, 0 failed)
  • No runtime behavior changes; change is entirely #[cfg(test)] code

Add a new #[cfg(test)] module that asserts each helper-generated
next_commands entry parses successfully via Cli::try_parse_from.
Covers all 11 entity surfaces (gene, variant, article, trial, disease,
pgx, drug, pathway, protein, adverse-event, device-event) including
shell-quoted multi-word arguments and conditional variant oncokb template.
@imaurer imaurer merged commit 6bc0702 into main Mar 12, 2026
3 checks passed
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