From 0104990296f5d363fe0e3c44de67594a41ad7875 Mon Sep 17 00:00:00 2001 From: Pyro57000 <147988717+Pyro57000@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:50:28 -0600 Subject: [PATCH] parser for net computers --- parse_net_computers/Cargo.lock | 7 +++++++ parse_net_computers/Cargo.toml | 8 ++++++++ parse_net_computers/src/main.rs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 parse_net_computers/Cargo.lock create mode 100644 parse_net_computers/Cargo.toml create mode 100644 parse_net_computers/src/main.rs diff --git a/parse_net_computers/Cargo.lock b/parse_net_computers/Cargo.lock new file mode 100644 index 0000000..9031e17 --- /dev/null +++ b/parse_net_computers/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "parse_net_computers" +version = "0.1.0" diff --git a/parse_net_computers/Cargo.toml b/parse_net_computers/Cargo.toml new file mode 100644 index 0000000..7519c38 --- /dev/null +++ b/parse_net_computers/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "parse_net_computers" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/parse_net_computers/src/main.rs b/parse_net_computers/src/main.rs new file mode 100644 index 0000000..ba4e46c --- /dev/null +++ b/parse_net_computers/src/main.rs @@ -0,0 +1,31 @@ +use std::fs; +use std::env; +use std::io::Write; + + +fn main() { + print!(" + ░█▀█░█▀▀░▀█▀░░░░░█▀▀░█▀█░█▄█░█▀█░█░█░▀█▀░█▀▀░█▀▄░░░░░█▀█░█▀█░█▀▄░█▀▀░█▀▀░█▀▄ + ░█░█░█▀▀░░█░░░░░░█░░░█░█░█░█░█▀▀░█░█░░█░░█▀▀░█▀▄░░░░░█▀▀░█▀█░█▀▄░▀▀█░█▀▀░█▀▄ + ░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░░░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀░░░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀ +"); + let args: Vec = env::args().collect(); + if args.len() != 3{ + print!(" +Usage: parse_net_computers /path/to/net/computer/output.txt /path/to/parsed/save/file.txt +"); + } + else{ + let net_computer_text = fs::read_to_string(&args[1]).expect("error reading input file"); + let net_computer_lines:Vec<&str> = net_computer_text.split_whitespace().collect(); + let mut outputfile = fs::File::create(&args[2]).expect("error creating output file"); + for computer in net_computer_lines{ + let mut filtered_computer = computer.to_owned(); + filtered_computer.pop(); + println!("\\\\{}", filtered_computer); + let output_line = format!("\\\\{}\n", filtered_computer); + outputfile.write_all(output_line.as_bytes()).expect("error writing output file"); + + } + } +}