Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions bolt-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bolt-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ eyre = "0.6.12"
thiserror = "2.0"
hex = "0.4.3"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "fmt"] }
reqwest = { version = "0.12.9", features = ["rustls-tls"] }
rand = "0.8.5"
lazy_static = "1.5.0"
Expand Down
9 changes: 9 additions & 0 deletions bolt-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ Options:

---

## Logging

```text
bolt --verbosity

Options:
-v, --verbosity Verbosity level of logs. Enter multiple times to increase the verbosity (e.g. -v, -vv, -vvv).
```

## Security

The Bolt CLI is designed to be used offline. It does not require any network connections
Expand Down
7 changes: 6 additions & 1 deletion bolt-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy::{
};
use clap::{
builder::styling::{AnsiColor, Color, Style},
Parser, Subcommand, ValueEnum,
ArgAction, Parser, Subcommand, ValueEnum,
};
use reqwest::Url;

Expand All @@ -20,6 +20,11 @@ pub struct Opts {
/// The subcommand to run.
#[clap(subcommand)]
pub command: Cmd,

/// specify log verbosity e.g (-v, -vv, -vvv, etc.)
/// errors will be logged regardless of the verbosity level
#[clap(short, long, global = true, env = "VERBOSITY", default_value_t=1, action = ArgAction::Count)]
pub verbosity: u8,
}

#[derive(Subcommand, Debug, Clone)]
Expand Down
14 changes: 12 additions & 2 deletions bolt-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ mod pb;
/// Contracts and interfaces bindings for interacting with the Bolt network.
mod contracts;

use tracing_subscriber::{fmt, prelude::*, EnvFilter};

#[tokio::main]
async fn main() -> eyre::Result<()> {
let _ = dotenvy::dotenv();
let _ = tracing_subscriber::fmt().with_target(false).try_init();

let opts = cli::Opts::parse();
let filtered_layer =
EnvFilter::builder().from_env_lossy().add_directive(opts.verbosity.to_string().parse()?);

let _ = tracing_subscriber::registry()
.with(fmt::layer().with_target(false))
.with(filtered_layer)
.try_init();

if let Err(err) = rustls::crypto::ring::default_provider().install_default() {
error!("Failed to install default TLS provider: {:?}", err);
}

cli::Opts::parse().command.run().await
opts.command.run().await
}
Loading