Giter Site home page Giter Site logo

Proper exit codes about cargo-binstall HOT 3 CLOSED

cargo-bins avatar cargo-bins commented on May 29, 2024 1
Proper exit codes

from cargo-binstall.

Comments (3)

somehowchris avatar somehowchris commented on May 29, 2024

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.

somehowchris avatar somehowchris commented on May 29, 2024

Or something like https://docs.rs/clap/latest/clap/error/struct.Error.html#method.context

from cargo-binstall.

passcod avatar passcod commented on May 29, 2024

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 and Failure (or whatever naming), and do our own result handling in main instead of returning an error so we exit UserAbort gracefully and print a pretty error with Failure.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.