Comments (3)
Would one be to have an Errors
enum something along the lines like reqwest
, so its actually typed, debuggable.
I could imagine cargo-binstall
also being useful for other clis, so expsing a crate api would be cool (and just a random though), so typed errors would also be useful.
Using this approach, the errors then could be "catched" by some formatting logic to output it nicely formatted and exit the cli with a non 0 exit code. This would also mean that the main function would be main() {}
and handle all the things inside
from cargo-binstall.
Or something like https://docs.rs/clap/latest/clap/error/struct.Error.html#method.context
from cargo-binstall.
I think specifically there's two different things here to think about:
- a human aborting the process by saying "no" to a prompt is a correct, expected end to the process and should return 0
- in the case of a dry run, if the options don't imply a script use, I think that's still an expected end. You shouldn't really do a dry-run in a script, I think?
- the process exiting on its own in CI without installing the package is unexpected and should exit with an error code
So I think the first concrete improvement here will be to split those two scenarios and exit differently. There's really two options I see here:
- continue to return
Ok(())
after printing a message for the former and return an error otherwise - make up a special error somehow (not sure how to specialise like that in
anyhow
, might need some figuring out or wrapping) that has (initially) two variants:UserAbort
andFailure
(or whatever naming), and do our own result handling in main instead of returning an error so we exitUserAbort
gracefully and print a pretty error withFailure
.
I prefer the second because it's cleaner and clearer at the type level but it may be a bit more work.
Once we've got that going and well separated, we can look into adding:
- more detail to errors
- different error codes for different errors (I'm sure there's a standard somewhere we can take inspiration from)
- this from the mega thread: "(thinking about feedback, we could have a
if this doesn't work for you, please open an issue with the following information <link>
in the help or something to help point people back here when things go wrong?)"
from cargo-binstall.
Related Issues (20)
- Linux: not working with wired? connection HOT 1
- Enable dry run only for cli release PRs HOT 1
- resolve log is too verbose HOT 2
- musl target change HOT 11
- Unnecessary warning about lack of `~/.git-credentials` HOT 3
- Question about the template macro HOT 2
- Consider adding -Zcross-crate-inline-threshold=always HOT 3
- Add cargo-run-bin to readme HOT 6
- cargo-binstall doesn't work behind corporate firewall HOT 3
- How to use binstall to download bin in *musl.tar.gz release package? HOT 7
- Please add support for scoop install in win10 HOT 4
- How to list installed binary? HOT 3
- Upgrade to hyper 1.0 once reqwest completed the upgrade HOT 1
- where is the cached downloaded file? HOT 1
- How to download bin with get/put but not git-api-token ? HOT 1
- How to skip fatal error HOT 4
- Using `cargo-binstall` with `cargo-run-bin` for fast CI in GitHub Actions HOT 4
- not updating .crates2.json HOT 5
- CI: add retry for steps/jobs on timeout. HOT 5
- feature: Improve retrying logic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-binstall.