parser for net computers
This commit is contained in:
7
parse_net_computers/Cargo.lock
generated
Normal file
7
parse_net_computers/Cargo.lock
generated
Normal 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"
|
||||
8
parse_net_computers/Cargo.toml
Normal file
8
parse_net_computers/Cargo.toml
Normal 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]
|
||||
31
parse_net_computers/src/main.rs
Normal file
31
parse_net_computers/src/main.rs
Normal 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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user