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

Provide examples when the default value or validation depends on other arguments #44

Closed
asarkar opened this issue Jan 21, 2018 · 4 comments

Comments

@asarkar
Copy link

asarkar commented Jan 21, 2018

Use case 1: If given argument is an existing Path, --force must be provided.
Use case 2: Default value depends on another argument.

@xenomachina
Copy link
Owner

For case 1 you need to make --force optional, and handle the error yourself. (You can throw a SystemExistException to have the normal handling take care of printing and exiting.)

For case 2, I don't think this actually worked before, but the fix for #47 made this possible. Once the next release comes out you'll be able to do something like:

class MyArgs(parser: ArgParser) {
    val a by parser.storing(TEST_HELP).default("")
    val b by parser.storing(TEST_HELP).default { "=$a" }
}

In this example, the default of b is a (and if a is unset, its default is used.)

The fix for that isn't released yet, but should be out in the next release.

@asarkar
Copy link
Author

asarkar commented Mar 26, 2018

Why is this ticket closed if there is no fix available yet? If I told the customer that I'd a fix in my head for the problem they reported in Prod, would they happily go away?

--force is always optional in any tool I know; in other words, no tool exists that forces me to use force.

@xenomachina
Copy link
Owner

Why is this ticket closed if there is no fix available yet?

You filed a single issue for two unrelated problems.

The first was asking how to do something. I told you how to do it.

The second was not possible, but is now possible with the code in master as of commit 413c8fa. It's pretty standard practice for open source projects to close issues once the fix is committed, not when actually released.

--force is always optional in any tool I know; in other words, no tool exists that forces me to use force.

I think there's a miscommunication somewhere. I said "you need to make --force optional", so what is the disagreement?

@asarkar
Copy link
Author

asarkar commented Mar 27, 2018

I misread the word "error" as "horror" in "you need to make --force optional, and handle the error yourself" and came to the conclusion that you implied I shouldn't go down that path. I checked commit 413c8fa and it looks like what I was looking for when I created this ticket. Thanks for the explanation.

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

No branches or pull requests

2 participants