Skip to content
This repository was archived by the owner on Aug 29, 2026. It is now read-only.

feat(0.2.1): reflect advanced Clap argument relationships - #13

Closed
zerosnacks wants to merge 4 commits into
masterfrom
feat/0.2.1
Closed

zerosnacks wants to merge 4 commits into
masterfrom
feat/0.2.1

Conversation

@zerosnacks

@zerosnacks zerosnacks commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR completes the advanced argument relationship reflection deferred from clap_schema 0.2.0.

It builds on the 0.2 invocation contract by exposing additional Clap semantics that affect whether a constructed invocation is valid, without changing the meaning of the existing 0.2 fields.

Relationship reflection

The contract now additionally exposes:

  • argument overrides;
  • argument requirements;
  • conditional requiredness;
  • required-unless rules;
  • conditional defaults;
  • default-missing values;
  • argument-group requirements;
  • argument-group conflicts.

These relationships are reflected from Clap's built command model rather than inferred through synthetic parsing.

Argument and group targets are represented by their stable Clap IDs so consumers can reason about relationships independently of display names or aliases.

Conditional defaults retain Clap's value-source semantics: values originating only from defaults do not satisfy defaultIf predicates. For group targets, equality predicates compare against the stable ID of the selected member.

Argument groups

Groups are now retained not only when they directly constrain cardinality, but also when referenced by another representable relationship.

Group requirements and conflicts are surfaced alongside membership, requiredness, and multiplicity.

Compatibility

This is an additive update to the 0.2 contract.

The new relationship properties are optional, and the 0.2 wire-format compatibility rules require consumers to tolerate additional optional fields. Existing 0.2.0 fields retain their meaning.

Dependency

This functionality depends on the read-only relationship reflection APIs introduced by clap-rs/clap#6494.

Edit: upstream PR has been closed, ticket has been opened for discussion: clap-rs/clap#6497

@zerosnacks zerosnacks added the blocked This is blocked label Aug 19, 2026
@zerosnacks
zerosnacks marked this pull request as ready for review August 19, 2026 15:53
@zerosnacks
zerosnacks marked this pull request as draft August 19, 2026 15:54
Base automatically changed from feat/0.2.0 to master August 19, 2026 16:05
@zerosnacks
zerosnacks marked this pull request as ready for review August 19, 2026 16:09
Comment thread Cargo.toml
Comment on lines +165 to +166
# Temporary until clap-rs/clap#6494 is merged and released.
clap = { git = "https://github.com/zerosnacks/clap", rev = "2883a7f13718bb4c3cf0456cf831176d20a2ae14", version = "4.6.6", default-features = false, features = ["std"] }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove

Comment thread deny.toml
Comment on lines +54 to +56
allow-git = [
"https://github.com/zerosnacks/clap", # Temporary for clap-rs/clap#6494
]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove

let facade = repository_root().to_string_lossy().replace('\\', "/");
let manifest = format!(
"[package]\nname = \"clap_schema-ui-{fixture}\"\nversion = \"0.0.0\"\nedition = \"2024\"\npublish = false\n\n[dependencies]\nclap = {{ version = \"4.6.6\", features = [\"derive\"] }}\nclap_schema = {{ path = \"{facade}\" }}\n"
"[package]\nname = \"clap_schema-ui-{fixture}\"\nversion = \"0.0.0\"\nedition = \"2024\"\npublish = false\n\n[dependencies]\nclap = {{ git = \"https://github.com/zerosnacks/clap\", rev = \"2883a7f13718bb4c3cf0456cf831176d20a2ae14\", version = \"4.6.6\", features = [\"derive\"] }}\nclap_schema = {{ path = \"{facade}\" }}\n"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove

@zerosnacks

Copy link
Copy Markdown
Member Author

Per clap-rs/clap#6497 (comment) it has been decided that the reflection API clap_schema relies on is not intentionally exposed, will not be expanded and it is unlikely that a breaking release will offer the functionality we rely on during migration.

@zerosnacks zerosnacks closed this Aug 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

blocked This is blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant