chshersh / tool-sync

🧰 Download pre-built binaries of all your favourite tools with a single command
https://crates.io/crates/tool-sync
Mozilla Public License 2.0
72 stars 17 forks source link

Introduce the 'OS' enum and improve error messages #110

Closed chshersh closed 1 year ago

chshersh commented 2 years ago

Currently, tool-sync matches the value of env::consts::OS with the hardcoded string to extract the relevant part of the asset name:

https://github.com/chshersh/tool-sync/blob/df7d4768c9cff2a91616bd9686bc928a52fc8c10/src/model/asset_name.rs#L18-L22

I propose to introduce an enum with 3 constructors. This should allow us to support more OSes in the future if we ever need. And it'll help to improve error messages easily.

So the issue includes the following tasks:

https://github.com/chshersh/tool-sync/blob/df7d4768c9cff2a91616bd9686bc928a52fc8c10/src/model/release.rs#L36-L40

It should be something like:

"Unknown asset selector for the current OS. Specify 'asset_name.{}' in the config.",
get_os(),