1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! RFC 121 §3: one shared mechanism for "reject unknown, refuse duplicate" — every argument
//! parser in this crate builds on this rather than each re-deciding the same absence differently.
//! Before this module existed, every parser had its own hand-rolled `match arg.as_str() { ... }`
//! loop: unknown arguments were refused inconsistently (some parsers, some not at all -- `status`
//! and `init`'s extra positionals had no parser to refuse anything), and every value-carrying flag
//! silently took its *last* occurrence with no refusal at all (`bundle export --ref X --ref Y`
//! exports `Y`, silently -- the handoff's own named victim, but not the only one: every `--ref`,
//! `--limit`, `--format`, and `-m`/`--message` flag in this crate had the identical shape).
//!
//! No new dependency (`prikk-cli` stays at zero third-party crates, `placement.rs` enforces it) --
//! this is a same-crate helper, not a parser library.
use crateCliError;
/// Mark a value-carrying flag as seen exactly once, refusing a second occurrence. `Option<T>` is
/// the "not yet seen" state regardless of what the flag's own resolved default will be, so a
/// flag with a non-`None` default (e.g. `--ref`'s `heads/main`) still refuses a literal repeat
/// rather than reading the first occurrence as "no value supplied yet."
pub
/// As [`SetOnce`], for a boolean presence flag (`--yes`, `--stop-on-first-error`, ...) that carries
/// no value of its own -- for these, "seen" and "value" are the same fact, so the flag's own `bool`
/// doubles as the seen-tracker.
pub
/// Consume the next token as a flag's required value, refusing if the flag was the last argument.
pub
/// An unrecognized argument -- one place to change the wording, and every call site gets
/// `CliError::Usage` rather than each site choosing (or forgetting to choose) that.
pub