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

Make run and throwable #96

Open
Blackjacx opened this issue Sep 25, 2020 · 1 comment
Open

Make run and throwable #96

Blackjacx opened this issue Sep 25, 2020 · 1 comment

Comments

@Blackjacx
Copy link

Blackjacx commented Sep 25, 2020

I already mentioned this request in #92. I think it is a very common use case to make all run commands throwable.

What I would like to avoid is the extra check for the error and manually print the error like this:

        let out = run("mint", args)

        if let error = out.error {
            print(out.stderror)
            throw error
        }

The following would be much cleaner imho and the failure reason could be part of the error or an underlying error maybe:

        let successfulOut = try run("mint", args)

Originally posted by @stherold in #92 (comment)

@kareman
Copy link
Owner

kareman commented Sep 26, 2020

You're right, it is a bit cumbersome the way it is now. The problem with your suggestion is that it makes it more cumbersome to get the result of a failing command. And it is a breaking change, so it would have to be in SwiftShell 6.0. But your use case is probably more common.

I've been wanting to improve the API for a long time now, but I just haven't been able to come up with a good solution that handles all aspects well, like error handling, synchronicity, shell interpreter, stdin, joined or separate stdout/stderror, printing output, piping output to another command, and probably even more that I haven't thought of yet.

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

2 participants