2022-03-28 18:41:35 -07:00
|
|
|
use eyre::Result;
|
2022-04-10 13:14:53 -07:00
|
|
|
use futures::TryFutureExt;
|
2022-03-28 18:41:35 -07:00
|
|
|
use paris::*;
|
2022-07-15 15:39:38 +00:00
|
|
|
use tracing_error::ErrorLayer;
|
|
|
|
|
use tracing_futures::WithSubscriber;
|
|
|
|
|
use tracing_subscriber::prelude::*;
|
|
|
|
|
use tracing_subscriber::{fmt, EnvFilter};
|
2022-03-28 18:41:35 -07:00
|
|
|
|
2022-07-15 15:39:38 +00:00
|
|
|
#[macro_use]
|
2022-03-28 18:41:35 -07:00
|
|
|
mod util;
|
|
|
|
|
|
2022-07-15 15:39:38 +00:00
|
|
|
mod subcommands;
|
|
|
|
|
|
|
|
|
|
#[derive(argh::FromArgs, Debug)]
|
2022-03-28 18:41:35 -07:00
|
|
|
/// The official Modrinth CLI
|
|
|
|
|
pub struct Args {
|
|
|
|
|
#[argh(subcommand)]
|
2022-07-15 15:39:38 +00:00
|
|
|
pub subcommand: subcommands::Subcommand,
|
2022-03-28 18:41:35 -07:00
|
|
|
}
|
|
|
|
|
|
2022-07-15 15:39:38 +00:00
|
|
|
#[tracing::instrument]
|
|
|
|
|
fn main() -> Result<()> {
|
2022-03-28 18:41:35 -07:00
|
|
|
let args = argh::from_env::<Args>();
|
2022-07-15 15:39:38 +00:00
|
|
|
|
|
|
|
|
color_eyre::install()?;
|
|
|
|
|
let filter = EnvFilter::try_from_default_env()
|
|
|
|
|
.or_else(|_| EnvFilter::try_new("info"))?;
|
|
|
|
|
|
|
|
|
|
let format = fmt::layer()
|
|
|
|
|
.without_time()
|
|
|
|
|
.with_writer(std::io::stderr)
|
|
|
|
|
.with_target(false)
|
|
|
|
|
.compact();
|
|
|
|
|
|
|
|
|
|
tracing_subscriber::registry()
|
|
|
|
|
.with(format)
|
|
|
|
|
.with(filter)
|
|
|
|
|
.with(ErrorLayer::default())
|
2022-06-27 15:53:25 -07:00
|
|
|
.init();
|
2022-03-28 18:41:35 -07:00
|
|
|
|
2022-07-15 15:39:38 +00:00
|
|
|
tokio::runtime::Builder::new_multi_thread()
|
|
|
|
|
.enable_all()
|
|
|
|
|
.build()?
|
|
|
|
|
.block_on(
|
|
|
|
|
async move {
|
|
|
|
|
args.dispatch()
|
|
|
|
|
.inspect_err(|_| error!("An error has occurred!\n"))
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
.with_current_subscriber(),
|
|
|
|
|
)
|
2022-03-28 18:41:35 -07:00
|
|
|
}
|