-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate cli function from main
- Loading branch information
1 parent
5726a60
commit 1854fd6
Showing
2 changed files
with
241 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
use clap::{Arg, ArgAction, Command}; | ||
|
||
// This function sets up the command line interface for the application using the clap library. | ||
// It defines the available commands and their arguments. | ||
pub fn cli_template() -> Command { | ||
Command::new("fluere") | ||
.version("0.6.2") | ||
.author("Skuld Norniern. <[email protected]>") | ||
.about("Netflow Capture Tool") | ||
.subcommand_required(true) | ||
.subcommand( | ||
Command::new("online") | ||
.about("Capture netflow online") | ||
.arg( | ||
Arg::new("csv") | ||
.help("Title of the exported csv file") | ||
.short('c') | ||
.long("csv") | ||
.default_value("output"), | ||
) | ||
.arg( | ||
Arg::new("list") | ||
.help("List of network interfaces") | ||
.short('l') | ||
.long("list") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("interface") | ||
.help("Select network interface to use [Required]") | ||
.short('i') | ||
.long("interface") | ||
//.required(true), | ||
) | ||
.arg( | ||
Arg::new("duration") | ||
.help("Set capture duration, in milliseconds (0: infinite)") | ||
.default_value("0") | ||
.short('d') | ||
.long("duration"), | ||
) | ||
.arg( | ||
Arg::new("timeout") | ||
.help("Set flow timeout, in milliseconds (0: infinite)") | ||
.default_value("600000") | ||
.short('t') | ||
.long("timeout"), | ||
) | ||
.arg( | ||
Arg::new("useMACaddress") | ||
.help("Set use MAC address on Key value [default: false]") | ||
.short('M') | ||
.long("useMAC") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("interval") | ||
.help("Set export interval, in milliseconds") | ||
.default_value("1800000") | ||
.short('I') | ||
.long("interval"), | ||
) | ||
.arg( | ||
Arg::new("sleep_windows") | ||
.help("Set inverval of thread pause for (only)MS Windows per n packet (need it for stopping random stop on Windows)") | ||
.default_value("10") | ||
.short('s') | ||
.long("sleep"), | ||
) | ||
.arg( | ||
Arg::new("verbose") | ||
.help("Set verbosity level") | ||
.default_value("1") | ||
.short('v') | ||
.long("verbose"), // 0: quiet, 1: normal,2: extended, 3: verbose | ||
), | ||
) | ||
.subcommand( | ||
Command::new("offline") | ||
.about("Convet pcap files to netflow") | ||
.arg( | ||
Arg::new("file") | ||
.help("Name of the input pcap file [Required]") | ||
.short('f') | ||
.long("file") | ||
.required(true), | ||
) | ||
.arg( | ||
Arg::new("csv") | ||
.help("Title of the exported csv file") | ||
.short('c') | ||
.long("csv") | ||
.default_value("output"), | ||
) | ||
.arg( | ||
Arg::new("timeout") | ||
.help("Set flow timeout, in milliseconds (0: infinite)") | ||
.default_value("600000") | ||
.short('t') | ||
.long("timeout"), | ||
) | ||
.arg( | ||
Arg::new("useMACaddress") | ||
.help("Set use MAC address on Key value [default: false]") | ||
.short('M') | ||
.long("useMAC") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("verbose") | ||
.help("Set verbosity level") | ||
.default_value("1") | ||
.short('v') | ||
.long("verbose"), // 0: quiet, 1: normal,2: extended, 3: verbose | ||
), | ||
) | ||
.subcommand( | ||
Command::new("live") | ||
.about("Capture netflow online with live TUI feedback") | ||
.arg( | ||
Arg::new("csv") | ||
.help("Title of the exported csv file") | ||
.short('c') | ||
.long("csv") | ||
.default_value("output"), | ||
) | ||
.arg( | ||
Arg::new("list") | ||
.help("List of network interfaces") | ||
.short('l') | ||
.long("list") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("interface") | ||
.help("Select network interface to use [Required]") | ||
.short('i') | ||
.long("interface") | ||
//.required(true), | ||
) | ||
.arg( | ||
Arg::new("duration") | ||
.help("Set capture duration, in milliseconds (0: infinite)") | ||
.default_value("0") | ||
.short('d') | ||
.long("duration"), | ||
) | ||
.arg( | ||
Arg::new("timeout") | ||
.help("Set flow timeout, in milliseconds (0: infinite)") | ||
.default_value("600000") | ||
.short('t') | ||
.long("timeout"), | ||
) | ||
.arg( | ||
Arg::new("useMACaddress") | ||
.help("Set use MAC address on Key value [default: false]") | ||
.short('M') | ||
.long("useMAC") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("interval") | ||
.help("Set export interval, in milliseconds") | ||
.default_value("1800000") | ||
.short('I') | ||
.long("interval"), | ||
) | ||
.arg( | ||
Arg::new("sleep_windows") | ||
.help("Set inverval of thread pause for (only)MS Windows per n packet (need it for stopping random stop on Windows)") | ||
.default_value("10") | ||
.short('s') | ||
.long("sleep"), | ||
) | ||
.arg( | ||
Arg::new("verbose") | ||
.help("Set verbosity level") | ||
.default_value("1") | ||
.short('v') | ||
.long("verbose"), // 0: quiet, 1: normal,2: extended, 3: verbose | ||
), | ||
) | ||
.subcommand( | ||
Command::new("pcap") | ||
.about("Collect packet and save to .pcap file") | ||
.arg( | ||
Arg::new("pcap") | ||
.help("Name of the output pcap files title [Required]") | ||
.short('p') | ||
.long("pcap") | ||
//.required(true), | ||
) | ||
.arg( | ||
Arg::new("interface") | ||
.help("Select network interface to use [Required]") | ||
.short('i') | ||
.long("interface") | ||
//.required(true), | ||
) | ||
.arg( | ||
Arg::new("duration") | ||
.help("Set capture duration, in milliseconds (0: infinite)") | ||
.default_value("0") | ||
.short('d') | ||
.long("duration"), | ||
) | ||
.arg( | ||
Arg::new("interval") | ||
.help("Set export interval, in milliseconds") | ||
.default_value("1800000") | ||
.short('I') | ||
.long("interval"), | ||
) | ||
.arg( | ||
Arg::new("sleep_windows") | ||
.help("Set inverval of thread pause for (only)MS Windows per n packet (need it for stopping random stop on Windows)") | ||
.default_value("10") | ||
.short('s') | ||
.long("sleep"), | ||
) | ||
.arg( | ||
Arg::new("list") | ||
.help("List of network interfaces") | ||
.short('l') | ||
.long("list") | ||
.action(ArgAction::SetTrue), | ||
) | ||
.arg( | ||
Arg::new("verbose") | ||
.help("Set verbosity level") | ||
.default_value("1") | ||
.short('v') | ||
.long("verbose"), // 0: quiet, 1: normal,2: extended, 3: verbose | ||
), | ||
) | ||
} | ||
|
||
|
Oops, something went wrong.