Skip to main content

Crate mandible_core

Crate mandible_core 

Source
Expand description

mandible-core: the shared intermediate representation (IR) every mandible extraction tier normalizes into, and the merge logic that combines several tiers’ output for the same node into one.

See spec §4. This crate has no knowledge of any specific tool, tier, or terminal library — it is pure data model plus the sanitization and merge rules that keep that data model trustworthy.

Structs§

Authority
The two-axis trust level a Source carries. See spec §4.4’s authority table — the tier with the best structure is frequently not the tier with the best prose, so merge resolves each axis independently rather than by a single priority order.
CommandNode
One command or subcommand in the tree: git, git rebase, git rebase --onto’s parent, and so on.
Example
A worked example: a command line plus an optional explanation.
Flag
A single flag/option, e.g. -i, --interactive.
Positional
A positional argument, e.g. <pathspec>....
Provenance
Which extraction source(s) contributed to an item, in contribution order, plus a confidence score set only by heuristic tiers.
Text
Sanitized, display-safe text.

Enums§

Axis
One axis of Authority: structural facts (names, nesting, arity, which flags exist) vs. prose (descriptions, summaries, examples).
FlagKey
Identifies a flag within a node’s flag list.
ManFormat
Which man page macro package produced a Source::ManPage item.
MergeError
Errors merge can return.
NodeRef
A reference to a command or a specific flag within the tree, by name path.
Source
The origin of a piece of extracted data. See spec §4.2 and §7.
ValueKind
Whether a flag takes a value, and if so, whether it’s required.

Constants§

MAX_TEXT_CHARS
Hard cap on sanitized text length, in chars. Applied after all other normalization. Generous enough for any legitimate flag description or man page section, small enough that a pathological multi-megabyte string from a misbehaving tool cannot make its way into a render buffer.

Functions§

is_command_name_shaped
True if s looks like a real command/subcommand name: lowercase, starting with a letter, and otherwise only letters/digits/_/./- (^[a-z][a-z0-9_.-]*$, spec §7 Tier B rule 3).
merge_flag_lists
Merge flags by identity (long name, else short letter, else description-as-fallback) across several already alias-paired flag lists, applying the same two-axis authority resolution per field.
merge_nodes
Merge several same-node extraction results into one, per spec §4.4.
merge_positional_lists
Merge positionals across candidate lists by name identity.
merge_subcommand_lists
Merge subcommand lists recursively by name (spec §4.4: “Subcommands merge recursively by name”).
pair_aliases
Unify flags that arrived as separate short/long rows from the same source, per spec §4.4: sources legitimately emit a flag’s short and long forms as distinct items (e.g. gh __complete pr - returns --repo and -R as separate rows with identical descriptions). Within one node’s flag list, items whose descriptions match exactly and whose short/long slots are complementary unify into one Flag. Must run before merge.
resolve
Resolve a name path to the CommandNode it addresses, starting from root. path includes root’s own name as its first element.
resolve_flag
Resolve a NodeRef to the flag it addresses, if any.
resolve_mut
Mutable counterpart of resolve, used by the extraction runner to splice a newly-extracted subtree into the cached tree in place.