Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

[modular] User-driven validation #235

Open
2 tasks done
epage opened this issue Dec 6, 2021 · 0 comments
Open
2 tasks done

[modular] User-driven validation #235

epage opened this issue Dec 6, 2021 · 0 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by epage
Tuesday Nov 09, 2021 at 14:38 GMT
Originally opened as clap-rs/clap#3008


Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Clap Version

master

Describe your use case

  • We want to get clap smaller (#1365) and right now validation adds bulk regardless of what parts people use
    • We could put parts behind a feature flag but that could end up getting messy
  • In require on arg from a subcommand clap-rs/clap#3005, a user requested specialized validation logic

Describe the solution you'd like

Define one or more App Validation trait

  • Validate: Takes a built App and ArgMatches as an input, reports errors
  • Requires: Takes a built App, ArgMatches, and args as input, reports which args are required
  • (maybe) Default value: Takes a built App, ArgMatches, and args as input, reports default values for them

Steps

  1. Refactor all requires, conflicts, etc APIs to be implemented in terms of this
  1. Expose the trait and structs to the user in a clap::validate
  2. Deprecate the old Arg functions so now only those using this API pay the cost due to dead code elimination

Alternatives, if applicable

No response

Additional Context

See also clap-rs/clap#2832

Risks are usability and performance. The most basic APIs, like required, we probably need to keep baked in. Its the special inter-arg interactions that we should be focusing on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant