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

feat: Add GetResult(expr, defThunk) #187

Merged
merged 4 commits into from
Dec 13, 2023
Merged

Conversation

bartelink
Copy link
Member

Useful to defer computation work (or raising of an exception in the course of that) to look up a fallback where a parameter is missing

@bartelink bartelink changed the title Add GetResult(expr, defThunk) feat: Add GetResult(expr, defThunk) Nov 28, 2023
@bartelink
Copy link
Member Author

Workaround is carting around:

type Argu.ParseResults<'T when 'T :> Argu.IArgParserTemplate> with
    member x.GetResult([<ReflectedDefinition>] e: Quotations.Expr<'Fields -> 'T>, f: unit -> 'Fields) = x.TryGetResult(e) |> Option.defaultWith f

@nojaf nojaf mentioned this pull request Dec 12, 2023
@nojaf
Copy link
Collaborator

nojaf commented Dec 13, 2023

Could you add a release note and a new version for this?
We can have another release with this.

@bartelink
Copy link
Member Author

Sure, 6.1.3, or another number?

@nojaf
Copy link
Collaborator

nojaf commented Dec 13, 2023

Not entirely sure, 6.1.3 sounds right to me. Although I don't have the greatest insight into this specific fix.

@bartelink
Copy link
Member Author

On reflection, I think the correct implementation may be a bit more involved...

Give me a while before we merge it...

@bartelink
Copy link
Member Author

@nojaf OK, happier with this
If the truth be told, I'm sill looking for a fully integrated way of having a <MandatoryOrFromEnvVar "name"> mechanism as I'm rappling for in #143 though!

@nojaf nojaf merged commit 92b9315 into fsprojects:master Dec 13, 2023
4 checks passed
@nojaf
Copy link
Collaborator

nojaf commented Dec 13, 2023

I'm going to try another publish with this fix.

@bartelink bartelink deleted the patch-1 branch December 13, 2023 14:20
@bartelink
Copy link
Member Author

Looks great, nice work (though I see my summary docs are lacking...)
https://fsprojects.github.io/Argu/reference/argu-parseresults-1.html#GetResult

bartelink added a commit to bartelink/Argu that referenced this pull request Feb 19, 2024
* Add GetResult(expr, defThunk)

* Update ParseResults.fs

Fell into same trap!

* Add changelog

* Add exception trapping + tests
bartelink added a commit to bartelink/Argu that referenced this pull request Feb 28, 2024
* Add GetResult(expr, defThunk)

* Update ParseResults.fs

Fell into same trap!

* Add changelog

* Add exception trapping + tests
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