Skip to content

Support async methods in MapResult extension method #248

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

Closed
kensykora opened this issue Oct 1, 2015 · 4 comments
Closed

Support async methods in MapResult extension method #248

kensykora opened this issue Oct 1, 2015 · 4 comments

Comments

@kensykora
Copy link

Inside my verb handlers I have async calls, and it'd be nice if there were support for async methods this way.

e.g.,

int Main(string[] args) {
  return Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions>(args)
    .MapResultAsync(
      async (AddOptions opts) => RunAddAndReturnExitCodeAsync(opts),
      async (CommitOptions opts) => RunCommitAndReturnExitCodeAsync(opts),
      async (CloneOptions opts) => RunCloneAndReturnExitCodeAsync(opts),
      errs => 1);
}
@gsscoder
Copy link
Owner

gsscoder commented Oct 5, 2015

📎 Please read: #250. Thanks for collaboration and patience! 😅
Giacomo
P.S.: valid only for me, if a main contrib. is available he's obviously free to support devs/users of the project.

@bpug
Copy link

bpug commented Aug 25, 2016

Try this :

var result = Parser.Default.ParseArguments<AddOptions, CommitOptions>(args);
var test = await  result.MapResult(
                async (AddOptions opts) => await RunAddAndReturnExitCodeAsync(opts),
                async (CommitOptionsopts) => await RunCommitAndReturnExitCodeAsync(opts),
                err => Task.FromResult(-1));

@xabikos
Copy link

xabikos commented May 15, 2017

The suggestion from @bpug worked for me.

@kensykora
Copy link
Author

Thanks, seems like a viable workaround.

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

No branches or pull requests

4 participants