MCPcopy Create free account
hub / github.com/adysec/tracker / parse_args

Function parse_args

tracker-checker/src/main.rs:939–970  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

937}
938
939fn parse_args() -> Result<(String, String, usize), String> {
940 let mut args = std::env::args().skip(1).collect::<Vec<_>>();
941 if args.is_empty() {
942 return Ok((
943 "trackers.txt".to_string(),
944 "trackers_best.txt".to_string(),
945 DEFAULT_WORKERS,
946 ));
947 }
948
949 let mut workers = DEFAULT_WORKERS;
950 if let Some(pos) = args.iter().position(|a| a == "--workers") {
951 if pos + 1 >= args.len() {
952 return Err("--workers requires a value".to_string());
953 }
954 workers = args[pos + 1]
955 .parse::<usize>()
956 .map_err(|_| "Invalid --workers value".to_string())?;
957 args.drain(pos..=pos + 1);
958 }
959
960 let input = args
961 .first()
962 .cloned()
963 .unwrap_or_else(|| "trackers.txt".to_string());
964 let output = args
965 .get(1)
966 .cloned()
967 .unwrap_or_else(|| "trackers_best.txt".to_string());
968
969 Ok((input, output, workers.max(1)))
970}
971
972fn status_tag(status: &Status) -> &'static str {
973 match status {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected