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]]
|
[[bin]]
|
||||||
name = "irtt-rs"
|
name = "irtt-rs"
|
||||||
path = "src/main.rs"
|
path = "src/bin/irtt-rs.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "irtt-cli"
|
name = "irtt-cli"
|
||||||
path = "src/main.rs"
|
path = "src/bin/irtt-cli.rs"
|
||||||
required-features = ["client"]
|
required-features = ["client"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "irtt-tui"
|
name = "irtt-tui"
|
||||||
path = "src/main.rs"
|
path = "src/bin/irtt-tui.rs"
|
||||||
required-features = ["tui"]
|
required-features = ["tui"]
|
||||||
|
|
||||||
[features]
|
[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},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
use irtt_cli::{
|
use crate::{
|
||||||
applet::{dispatch_from_argv, AppletDispatch, RequestedApplet},
|
applet::{dispatch_from_argv, AppletDispatch, RequestedApplet},
|
||||||
signal::install_signal_handler,
|
signal::install_signal_handler,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
pub fn main() -> ExitCode {
|
||||||
match run_from_env() {
|
match run_from_env() {
|
||||||
Ok(()) => ExitCode::SUCCESS,
|
Ok(()) => ExitCode::SUCCESS,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -48,8 +48,8 @@ fn run_client_applet(
|
|||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
let args = irtt_cli::cmd::client::ClientArgs::parse_from(argv);
|
let args = crate::cmd::client::ClientArgs::parse_from(argv);
|
||||||
irtt_cli::cmd::client::run_stream(args, shutdown_requested)
|
crate::cmd::client::run_stream(args, shutdown_requested)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "client"))]
|
#[cfg(not(feature = "client"))]
|
||||||
@@ -67,8 +67,8 @@ fn run_tui_applet(
|
|||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
let args = irtt_cli::cmd::tui::TuiArgs::parse_from(argv);
|
let args = crate::cmd::tui::TuiArgs::parse_from(argv);
|
||||||
irtt_cli::cmd::tui::run_tui(args, shutdown_requested)
|
crate::cmd::tui::run_tui(args, shutdown_requested)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "tui"))]
|
#[cfg(not(feature = "tui"))]
|
||||||
@@ -2,5 +2,7 @@
|
|||||||
|
|
||||||
pub mod applet;
|
pub mod applet;
|
||||||
pub mod cmd;
|
pub mod cmd;
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod entry;
|
||||||
pub mod shared;
|
pub mod shared;
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
Reference in new issue
Block a user