diff --git a/ROADMAP.md b/ROADMAP.md index 0a85a69..ff4ca97 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -126,6 +126,7 @@ The experimental eBPF support provides efficient process identification but has - [x] **Help Screen**: Toggle help screen with keyboard shortcuts (h key) - [x] **Clipboard Support**: Copy remote address to clipboard (c key) - [x] **Service/Port Toggle**: Toggle between service names and port numbers (p key) +- [x] **Platform-Specific CLI Help**: Show only relevant options per platform (hide Linux sandbox options on macOS, hide PKTAP notes on Linux) - [ ] **Resizable Columns**: Dynamic column width adjustment - [ ] **Connection Grouping**: Group connections by process/service - [ ] **ASCII Graphs**: Terminal-based graphs for bandwidth/packet visualization diff --git a/src/cli.rs b/src/cli.rs index fbbeab2..2a5fa7c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,19 @@ use clap::{Arg, Command}; +#[cfg(target_os = "linux")] +const INTERFACE_HELP: &str = "Network interface to monitor (use \"any\" to capture all interfaces)"; + +#[cfg(not(target_os = "linux"))] +const INTERFACE_HELP: &str = "Network interface to monitor"; + +#[cfg(target_os = "macos")] +const BPF_HELP: &str = "BPF filter expression for packet capture (e.g., \"tcp port 443\"). Note: Using a BPF filter disables PKTAP (process info falls back to lsof)"; + +#[cfg(not(target_os = "macos"))] +const BPF_HELP: &str = "BPF filter expression for packet capture (e.g., \"tcp port 443\", \"dst port 80\")"; + pub fn build_cli() -> Command { - Command::new("rustnet") + let cmd = Command::new("rustnet") .version(env!("CARGO_PKG_VERSION")) .author("Network Monitor") .about("Cross-platform network monitoring tool") @@ -10,7 +22,7 @@ pub fn build_cli() -> Command { .short('i') .long("interface") .value_name("INTERFACE") - .help("Network interface to monitor") + .help(INTERFACE_HELP) .required(false), ) .arg( @@ -61,20 +73,25 @@ pub fn build_cli() -> Command { .short('f') .long("bpf-filter") .value_name("FILTER") - .help("BPF filter expression for packet capture (e.g., \"tcp port 443\", \"dst port 80\"). Note: On macOS, using a BPF filter disables PKTAP (process info falls back to lsof)") + .help(BPF_HELP) .required(false), - ) + ); + + #[cfg(target_os = "linux")] + let cmd = cmd .arg( Arg::new("no-sandbox") .long("no-sandbox") - .help("Disable Landlock sandboxing (Linux only)") + .help("Disable Landlock sandboxing") .action(clap::ArgAction::SetTrue), ) .arg( Arg::new("sandbox-strict") .long("sandbox-strict") - .help("Require full sandbox enforcement or exit (Linux only)") + .help("Require full sandbox enforcement or exit") .action(clap::ArgAction::SetTrue) .conflicts_with("no-sandbox"), - ) + ); + + cmd }