Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setOptionValueWithSource and getOptionValueSource #1613

Merged
merged 2 commits into from
Sep 27, 2021

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Sep 25, 2021

Pull Request

Problem

  • It is difficult for clients to detect whether options with default values have been specified on the command-line.
  • It is difficult for clients to manage priorities when merging in option values from different sources.

Resolves: #1584 (comment)
Related: #151 #328 #1394 #1541 #1595 #1607

Solution

The work to support .env() had to solve similar problems, and I had config and cli-detection in mind.

Make .setOptionValueWithSource() public. Add matching .getOptionValueSource().

(These routines are quite low-level with long names, but my thinking is they are tools for allowing clients to roll their own custom behaviours and won't be used by the majority of users.)

ChangeLog

  • Added: .getOptionValueSource() and .setOptionValueWithSource(), where source is one of 'default', 'env', 'config', 'cli'

Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shadowspawn shadowspawn merged commit 6e00f44 into tj:develop Sep 27, 2021
@shadowspawn shadowspawn deleted the feature/option-value-source branch September 27, 2021 07:09
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Sep 27, 2021
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Oct 22, 2021
@shadowspawn
Copy link
Collaborator Author

Released in Commander v8.3.0

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.

2 participants