refactor(cli): separate binary entry points from library logic
Move the main execution logic to a dedicated internal module and create distinct entry files for each binary to improve project structure and build configuration.
This commit is contained in:
1 parent
d05d6a941b
commit
f1d442d798
6 files changed
+26
-9
No files matched your search
@@ -16,16 +16,16 @@ doc = false
|
||||
|
||||
[[bin]]
|
||||
name = "irtt-rs"
|
||||
path = "src/main.rs"
|
||||
path = "src/bin/irtt-rs.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "irtt-cli"
|
||||
path = "src/main.rs"
|
||||
path = "src/bin/irtt-cli.rs"
|
||||
required-features = ["client"]
|
||||
|
||||
[[bin]]
|
||||
name = "irtt-tui"
|
||||
path = "src/main.rs"
|
||||
path = "src/bin/irtt-tui.rs"
|
||||
required-features = ["tui"]
|
||||
|
||||
[features]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
irtt_cli::entry::main()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
irtt_cli::entry::main()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
use std::process::ExitCode;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
irtt_cli::entry::main()
|
||||
}
|
||||
@@ -5,12 +5,12 @@ use std::{
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
};
|
||||
|
||||
use irtt_cli::{
|
||||
use crate::{
|
||||
applet::{dispatch_from_argv, AppletDispatch, RequestedApplet},
|
||||
signal::install_signal_handler,
|
||||
};
|
||||
|
||||
fn main() -> ExitCode {
|
||||
pub fn main() -> ExitCode {
|
||||
match run_from_env() {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(err) => {
|
||||
@@ -48,8 +48,8 @@ fn run_client_applet(
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use clap::Parser;
|
||||
|
||||
let args = irtt_cli::cmd::client::ClientArgs::parse_from(argv);
|
||||
irtt_cli::cmd::client::run_stream(args, shutdown_requested)
|
||||
let args = crate::cmd::client::ClientArgs::parse_from(argv);
|
||||
crate::cmd::client::run_stream(args, shutdown_requested)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "client"))]
|
||||
@@ -67,8 +67,8 @@ fn run_tui_applet(
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use clap::Parser;
|
||||
|
||||
let args = irtt_cli::cmd::tui::TuiArgs::parse_from(argv);
|
||||
irtt_cli::cmd::tui::run_tui(args, shutdown_requested)
|
||||
let args = crate::cmd::tui::TuiArgs::parse_from(argv);
|
||||
crate::cmd::tui::run_tui(args, shutdown_requested)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tui"))]
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
pub mod applet;
|
||||
pub mod cmd;
|
||||
#[doc(hidden)]
|
||||
pub mod entry;
|
||||
pub mod shared;
|
||||
pub mod signal;
|
||||
Reference in new issue
Block a user