cargo-binstall/crates/bin/src/main.rs
Jiahao XU a69db83aa6
Fix error reporting in main and move all arg validation into fn args::parse (#585)
* Fix reporting parsing error from `args::parse`
   Report it in `args::parse` by using `Args::command().error(...).exit()`
   instead of returning `BinstallError`.
* Rm unused variant `BinstallError::OverrideOptionUsedWithMultiInstall`
* Refactor: Move `strategies` validation into `args::parse`
* Rm unused variant `BinstallError::InvalidStrategies`
* Add new unit test `args::test::verify_cli`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-12-03 11:57:50 +00:00

38 lines
898 B
Rust

use std::time::Instant;
use binstalk::helpers::jobserver_client::LazyJobserverClient;
use tracing::debug;
use cargo_binstall::{
args,
bin_util::{run_tokio_main, MainExit},
entry,
logging::logging,
};
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() -> MainExit {
// This must be the very first thing to happen
let jobserver_client = LazyJobserverClient::new();
let args = args::parse();
if args.version {
println!("{}", env!("CARGO_PKG_VERSION"));
MainExit::Success(None)
} else {
logging(args.log_level, args.json_output);
let start = Instant::now();
let result = run_tokio_main(entry::install_crates(args, jobserver_client));
let done = start.elapsed();
debug!("run time: {done:?}");
MainExit::new(result, done)
}
}