parser for net computers

This commit is contained in:
Pyro57000
2023-11-20 10:50:28 -06:00
committed by GitHub
parent fb7692fc56
commit 0104990296
3 changed files with 46 additions and 0 deletions

7
parse_net_computers/Cargo.lock generated Normal file
View File

@@ -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"

View File

@@ -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]

View File

@@ -0,0 +1,31 @@
use std::fs;
use std::env;
use std::io::Write;
fn main() {
print!("
░█▀█░█▀▀░▀█▀░░░░░█▀▀░█▀█░█▄█░█▀█░█░█░▀█▀░█▀▀░█▀▄░░░░░█▀█░█▀█░█▀▄░█▀▀░█▀▀░█▀▄
░█░█░█▀▀░░█░░░░░░█░░░█░█░█░█░█▀▀░█░█░░█░░█▀▀░█▀▄░░░░░█▀▀░█▀█░█▀▄░▀▀█░█▀▀░█▀▄
░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░░░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀░░░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀
");
let args: Vec<String> = 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");
}
}
}