Skip to content

[modular] User-driven values (defaults, env vars, implied values, etc) #4793

@epage

Description

@epage

With clap today, each value source needs to be hard coded, including

When new use cases arise, users either have to

It would help if clap had an API for users to provide their own systems for this. See also #3476.

Example unsupported use cases

default_value and default_missing_value are integral to Actions, so I'm thinking we leave those as built-in

Requirements

  • Know the source for existing relevant arg values
  • Able to set the source for value
  • Able to augment the help description of a specific argument with details
  • Ideally help uses with ValueSource precedence
  • Ideally leverage built-in Action behavior
  • Ideally not so unergonomic to be unuseful

Tools

  • Plugin API to allow storing arbitrary data on Command/Arg
  • Blanket impl of a trait for functions
  • Into to allow custom plugin data to be converted to the plugin type

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parsingArea: Parser's logic and needs it changed somehow.C-enhancementCategory: Raise on the bar on expectationsS-waiting-on-designStatus: Waiting on user-facing design to be resolved before implementing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions