Itchy
This commit is contained in:
commit
feaa65e21a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
25
Cargo.lock
generated
Normal file
25
Cargo.lock
generated
Normal file
|
@ -0,0 +1,25 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "rash"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.124"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "rash"
|
||||
version = "0.1.0"
|
||||
authors = ["able <abl3theabove@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
toml="*"
|
68
src/main.rs
Normal file
68
src/main.rs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Rash
|
||||
//Rusty bASH
|
||||
// Really Awesome SHell
|
||||
use std::io::Write;
|
||||
use std::io::{stdin, stdout};
|
||||
|
||||
use toml::Value;
|
||||
|
||||
const VALUE: &str = "
|
||||
cursor='> '
|
||||
";
|
||||
|
||||
const VERSION: &str = "0.1.0";
|
||||
fn main() {
|
||||
let value = VALUE.parse::<Value>().unwrap();
|
||||
let motd = "frick";
|
||||
let terminal_cursor = value["cursor"].as_str();
|
||||
|
||||
println!("{}", value);
|
||||
|
||||
clear_term();
|
||||
println!("{}", motd);
|
||||
|
||||
loop {
|
||||
print!("{}", terminal_cursor.unwrap());
|
||||
let _err = stdout().flush(); // Excplicitly flush to ensure > gets printed
|
||||
// handle the _err
|
||||
let mut input = String::new();
|
||||
stdin().read_line(&mut input).unwrap(); // read_line leaves a trailing newline, which trim removes
|
||||
let command = input.trim();
|
||||
match command {
|
||||
"rush" => {
|
||||
println!("Version: {}", VERSION);
|
||||
} // Maybe parse via clap
|
||||
"clear()" | "clean()" => {
|
||||
clear_term();
|
||||
}
|
||||
"random()" => {
|
||||
println!("1"); // this has been decided as the cryptographically secure random
|
||||
}
|
||||
"script()" => {
|
||||
let mut script = String::new();
|
||||
loop {
|
||||
let mut line = String::new();
|
||||
stdin().read_line(&mut line).unwrap(); // read_line leaves a trailing
|
||||
line = line.trim().to_string();
|
||||
if line == "end()" {
|
||||
println!("{}", script);
|
||||
break;
|
||||
} else {
|
||||
// append line to script
|
||||
script = format!("{}\n{}", script, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
"ls" => {
|
||||
println!("bonk");
|
||||
}
|
||||
_ => {
|
||||
println!("Command {} not found", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_term() {
|
||||
print!("\x1B[2J\x1B[1;1H");
|
||||
}
|
Loading…
Reference in a new issue