Skip to content

feat(ParseConfig): Add record + Parse(config) overload (additive)#307

Open
dimension-zero wants to merge 3 commits into
fsprojects:masterfrom
dimension-zero:pr/19-parser-config-record
Open

feat(ParseConfig): Add record + Parse(config) overload (additive)#307
dimension-zero wants to merge 3 commits into
fsprojects:masterfrom
dimension-zero:pr/19-parser-config-record

Conversation

@dimension-zero
Copy link
Copy Markdown
Contributor

feat(ParseConfig): Add record + Parse(config) overload (additive)

  • ArgumentParser.fs: Introduce public ParseConfig record carrying
    Inputs, ConfigurationReader, IgnoreMissing, IgnoreUnrecognized,
    RaiseOnUsage. Provide ParseConfig.Default reproducing the historical
    Parse(...) defaults.
  • New Parse(config: ParseConfig) overload delegates to the existing
    Parse(?inputs, ?configurationReader, ...) implementation. All current
    overloads remain untouched, so existing callers see no shape change.

Useful when hosts want to layer configuration programmatically (e.g.
merging container-provided defaults with user overrides) rather than
juggling many optional method arguments.


test(ParseConfig): Add coverage for ParseConfig record + Parse(config)

6 new tests:

  • ParseConfig.Default holds the historical defaults (None inputs, None
    reader, false IgnoreMissing/IgnoreUnrecognized, true RaiseOnUsage).
  • Parse(config with explicit inputs) parses those inputs.
  • Parse(config) matches Parse(?inputs, ...) for the same shape.
  • IgnoreMissing=true skips the mandatory check on empty inputs.
  • IgnoreUnrecognized=true gathers unknown args into UnrecognizedCliParams.
  • ConfigurationReader provided via config sources AppSettings entries.

A separate non-mandatory schema is used for the AppSettings test because
Argu's missing-mandatory check fires from CLI parsing even when AppSettings
provides a value (existing behaviour, not introduced by PR 19).

Net suite size on this branch: 112 -> 118.


dimension-zero and others added 3 commits May 23, 2026 18:01
* ArgumentParser.fs: Introduce public ParseConfig record carrying
  Inputs, ConfigurationReader, IgnoreMissing, IgnoreUnrecognized,
  RaiseOnUsage. Provide ParseConfig.Default reproducing the historical
  Parse(...) defaults.
* New Parse(config: ParseConfig) overload delegates to the existing
  Parse(?inputs, ?configurationReader, ...) implementation. All current
  overloads remain untouched, so existing callers see no shape change.

Useful when hosts want to layer configuration programmatically (e.g.
merging container-provided defaults with user overrides) rather than
juggling many optional method arguments.
6 new tests:
* ParseConfig.Default holds the historical defaults (None inputs, None
  reader, false IgnoreMissing/IgnoreUnrecognized, true RaiseOnUsage).
* Parse(config with explicit inputs) parses those inputs.
* Parse(config) matches Parse(?inputs, ...) for the same shape.
* IgnoreMissing=true skips the mandatory check on empty inputs.
* IgnoreUnrecognized=true gathers unknown args into UnrecognizedCliParams.
* ConfigurationReader provided via config sources AppSettings entries.

A separate non-mandatory schema is used for the AppSettings test because
Argu's missing-mandatory check fires from CLI parsing even when AppSettings
provides a value (existing behaviour, not introduced by PR 19).

Net suite size on this branch: 112 -> 118.
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