You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
1.9 KiB
87 lines
1.9 KiB
4 years ago
|
#![cfg_attr(nightly, feature(label_break_value))]
|
||
|
|
||
|
#![allow(dead_code)]
|
||
|
|
||
|
#[macro_use] extern crate tracing;
|
||
|
use std::{
|
||
|
convert::{TryFrom, TryInto},
|
||
|
};
|
||
|
use color_eyre::{
|
||
|
eyre::{
|
||
|
self,
|
||
|
WrapErr,
|
||
|
},
|
||
|
Help, SectionExt,
|
||
|
};
|
||
|
use lazy_static::lazy_static;
|
||
|
use serde::{Serialize, Deserialize};
|
||
|
|
||
|
pub const CURRENT_VERSION: version::Version = version::Version::new(0,0,0,version::Tag::Prerelease);
|
||
|
|
||
|
mod ext;
|
||
|
use ext::*;
|
||
|
mod version;
|
||
|
mod config;
|
||
|
mod args;
|
||
|
|
||
|
/*/// Dispatch params operations that can be handled at top level (i.e. `Help`)
|
||
|
async fn dispatch_args() -> Result<args::Operation, eyre::Report>
|
||
|
{
|
||
|
match args::parse_args().await
|
||
|
.with_section(move || std::env::args().skip(1).join("\n").header("Input args were:"))? {
|
||
|
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
macro_rules! cfg_debug {
|
||
|
(if {$($if:tt)*} else {$($else:tt)*}) => {
|
||
|
{
|
||
|
cfg_if::cfg_if!{
|
||
|
if #[cfg(debug_assertions)] {
|
||
|
$($if)*
|
||
|
} else {
|
||
|
$($else)*
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
fn install_tracing() {
|
||
|
use tracing_error::ErrorLayer;
|
||
|
use tracing_subscriber::prelude::*;
|
||
|
use tracing_subscriber::{fmt, EnvFilter};
|
||
|
|
||
|
let fmt_layer = fmt::layer().with_target(false);
|
||
|
let filter_layer = EnvFilter::try_from_default_env()
|
||
|
.or_else(|_| EnvFilter::try_new("info"))
|
||
|
.unwrap();
|
||
|
|
||
|
tracing_subscriber::registry()
|
||
|
.with(filter_layer)
|
||
|
.with(fmt_layer)
|
||
|
.with(ErrorLayer::default())
|
||
|
.init();
|
||
|
}
|
||
|
|
||
|
async fn work(op: config::Operation) -> Result<(), eyre::Report>
|
||
|
{
|
||
|
todo!()
|
||
|
}
|
||
|
|
||
|
#[instrument]
|
||
|
#[tokio::main]
|
||
|
async fn main() -> Result<(), eyre::Report> {
|
||
|
install_tracing();
|
||
|
color_eyre::install()?;
|
||
|
|
||
|
trace!("Parsing args");
|
||
|
let args = args::parse_args().await?;
|
||
|
|
||
|
work(args).await
|
||
|
.with_suggestion(|| "Run with `RUST_LOG=\"debug\"` environment variable for more detailed logging")
|
||
|
.with_suggestion(|| "Run with `RUST_LOG=\"trace\"` environment variable for extremely detailed logging")?;
|
||
|
|
||
|
Ok(())
|
||
|
}
|