feat: add support for tokio-console
This commit is contained in:
parent
8305715471
commit
1568b7e08a
5 changed files with 18 additions and 2 deletions
|
@ -22,10 +22,11 @@ rand = "0.8"
|
||||||
reqwest = { version = "0.12" , features = ["multipart", "stream"]}
|
reqwest = { version = "0.12" , features = ["multipart", "stream"]}
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tokio = { version = "1.41", features = ["full"] }
|
tokio = { version = "1.41", features = ["full", "tracing"] }
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
|
console-subscriber = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert2 = "0.3"
|
assert2 = "0.3"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
[tools]
|
[tools]
|
||||||
"cargo:cargo-llvm-cov" = "latest"
|
"cargo:cargo-llvm-cov" = "latest"
|
||||||
"cargo:cargo-tarpaulin" = "latest"
|
"cargo:cargo-tarpaulin" = "latest"
|
||||||
|
"cargo:tokio-console" = "latest"
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -32,6 +32,8 @@ const NAME: &str = "trello-to-deck";
|
||||||
pub struct Commands {
|
pub struct Commands {
|
||||||
#[clap(long, action = clap::ArgAction::SetTrue)]
|
#[clap(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub log: bool,
|
pub log: bool,
|
||||||
|
#[clap(long, action = clap::ArgAction::SetTrue)]
|
||||||
|
pub tokio_console: bool,
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub command: Command,
|
pub command: Command,
|
||||||
}
|
}
|
||||||
|
@ -95,7 +97,14 @@ impl FullCtx {
|
||||||
|
|
||||||
#[cfg_attr(test, mutants::skip)]
|
#[cfg_attr(test, mutants::skip)]
|
||||||
pub async fn run(ctx: &Ctx, commands: &Commands) -> color_eyre::Result<()> {
|
pub async fn run(ctx: &Ctx, commands: &Commands) -> color_eyre::Result<()> {
|
||||||
if commands.log {
|
if commands.tokio_console {
|
||||||
|
use tracing_subscriber::prelude::*;
|
||||||
|
let console_layer = console_subscriber::spawn();
|
||||||
|
tracing_subscriber::registry()
|
||||||
|
.with(console_layer)
|
||||||
|
.with(tracing_subscriber::fmt::layer())
|
||||||
|
.init();
|
||||||
|
} else if commands.log {
|
||||||
tracing::subscriber::set_global_default(
|
tracing::subscriber::set_global_default(
|
||||||
tracing_subscriber::FmtSubscriber::builder()
|
tracing_subscriber::FmtSubscriber::builder()
|
||||||
.with_max_level(tracing::Level::TRACE)
|
.with_max_level(tracing::Level::TRACE)
|
||||||
|
|
|
@ -7,12 +7,14 @@ use http::StatusCode;
|
||||||
fn test_commands_log_flag() {
|
fn test_commands_log_flag() {
|
||||||
let commands = Commands {
|
let commands = Commands {
|
||||||
log: true,
|
log: true,
|
||||||
|
tokio_console: false,
|
||||||
command: Command::Init,
|
command: Command::Init,
|
||||||
};
|
};
|
||||||
assert!(commands.log);
|
assert!(commands.log);
|
||||||
|
|
||||||
let commands = Commands {
|
let commands = Commands {
|
||||||
log: false,
|
log: false,
|
||||||
|
tokio_console: false,
|
||||||
command: Command::Init,
|
command: Command::Init,
|
||||||
};
|
};
|
||||||
assert!(!commands.log);
|
assert!(!commands.log);
|
||||||
|
@ -132,6 +134,7 @@ async fn test_run() -> Result<()> {
|
||||||
|
|
||||||
let commands = Commands {
|
let commands = Commands {
|
||||||
log: false,
|
log: false,
|
||||||
|
tokio_console: false,
|
||||||
command: Command::Check,
|
command: Command::Check,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ async fn when_file_does_not_exist_should_create() {
|
||||||
let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer());
|
let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer());
|
||||||
let commands = Commands {
|
let commands = Commands {
|
||||||
log: false,
|
log: false,
|
||||||
|
tokio_console: false,
|
||||||
command: Command::Init,
|
command: Command::Init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ async fn when_file_exists_should_err() {
|
||||||
let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer());
|
let ctx = given::a_context(fs.as_real(), given::a_network().into(), given::a_printer());
|
||||||
let commands = Commands {
|
let commands = Commands {
|
||||||
log: false,
|
log: false,
|
||||||
|
tokio_console: false,
|
||||||
command: Command::Init,
|
command: Command::Init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue