refactor: binary crate — thin main.rs + cli.rs dispatch
Slim binary that depends on sunbeam-sdk for all logic. Replaces 62 crate:: refs with sunbeam_sdk::. Tracing filter updated to include sunbeam_sdk=info.
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@@ -3550,6 +3550,19 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "sunbeam"
|
name = "sunbeam"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"clap",
|
||||||
|
"rustls",
|
||||||
|
"sunbeam-sdk",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sunbeam-sdk"
|
||||||
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3569,7 +3582,6 @@ dependencies = [
|
|||||||
"rsa",
|
"rsa",
|
||||||
"russh",
|
"russh",
|
||||||
"russh-keys",
|
"russh-keys",
|
||||||
"rustls",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
@@ -3580,7 +3592,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
1050
sunbeam/src/cli.rs
Normal file
1050
sunbeam/src/cli.rs
Normal file
File diff suppressed because it is too large
Load Diff
39
sunbeam/src/main.rs
Normal file
39
sunbeam/src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
mod cli;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// Install rustls crypto provider (ring) before any TLS operations.
|
||||||
|
rustls::crypto::ring::default_provider()
|
||||||
|
.install_default()
|
||||||
|
.expect("Failed to install rustls crypto provider");
|
||||||
|
|
||||||
|
// Initialize tracing subscriber.
|
||||||
|
// Respects RUST_LOG env var (e.g. RUST_LOG=debug, RUST_LOG=sunbeam=trace).
|
||||||
|
// Default: warn for dependencies, info for sunbeam + sunbeam_sdk.
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
.with_env_filter(
|
||||||
|
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
||||||
|
tracing_subscriber::EnvFilter::new("sunbeam=info,sunbeam_sdk=info,warn")
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.with_target(false)
|
||||||
|
.with_writer(std::io::stderr)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
match cli::dispatch().await {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(e) => {
|
||||||
|
let code = e.exit_code();
|
||||||
|
tracing::error!("{e}");
|
||||||
|
|
||||||
|
// Print source chain for non-trivial errors
|
||||||
|
let mut source = std::error::Error::source(&e);
|
||||||
|
while let Some(cause) = source {
|
||||||
|
tracing::debug!("caused by: {cause}");
|
||||||
|
source = std::error::Error::source(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::process::exit(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user