wrote some more stuff
This commit is contained in:
33
Cargo.lock
generated
33
Cargo.lock
generated
@@ -437,6 +437,16 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "term_size"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tetanus_client"
|
||||
version = "0.1.0"
|
||||
@@ -446,6 +456,7 @@ dependencies = [
|
||||
"colored",
|
||||
"dns-lookup",
|
||||
"num_cpus",
|
||||
"term_size",
|
||||
"tokio",
|
||||
"walkdir",
|
||||
]
|
||||
@@ -528,6 +539,22 @@ version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
@@ -537,6 +564,12 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
|
||||
@@ -9,5 +9,6 @@ clap = { version = "4.5.51", features = ["derive"] }
|
||||
colored = "3.0.0"
|
||||
dns-lookup = "3.0.1"
|
||||
num_cpus = "1.17.0"
|
||||
term_size = "0.3.2"
|
||||
tokio = { version = "1.48.0", features = ["full"] }
|
||||
walkdir = "2.5.0"
|
||||
|
||||
36
src/cli.rs
36
src/cli.rs
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
commands::{ToolArgument, build_args, build_tools},
|
||||
lib::{Destination, Message, Project},
|
||||
lib::{self, Destination, Message, Project},
|
||||
load_projects, load_settings, print_error, print_success,
|
||||
};
|
||||
use std::{path::PathBuf, thread::sleep, time::Duration};
|
||||
@@ -161,6 +161,30 @@ pub async fn cli(
|
||||
};
|
||||
main_tx.send(message).await.unwrap();
|
||||
break;
|
||||
} else if user_command_name == String::from("help") {
|
||||
let mut message = Message {
|
||||
source: Destination::Console,
|
||||
destination: Destination::Console,
|
||||
content: String::new(),
|
||||
};
|
||||
if user_command_args.len() > 0 {
|
||||
for command in &tool_commands {
|
||||
if command.name == user_command_args[0] {
|
||||
message.content = command.help.clone();
|
||||
console_tx.send(message.clone()).await.unwrap();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mut help_table = lib::Table::default();
|
||||
let mut data = vec![format!("command|help")];
|
||||
for command in &tool_commands {
|
||||
data.push(format!("{}|{}", command.name, command.help));
|
||||
}
|
||||
help_table.build(data);
|
||||
message.content = help_table.get_table();
|
||||
console_tx.send(message.clone()).await.unwrap();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let mut valid_command = false;
|
||||
let mut command_to_run = tool_commands[0].clone();
|
||||
@@ -271,14 +295,18 @@ pub async fn cli(
|
||||
"PROMPT" => {
|
||||
let input_handle = tokio::spawn(console_user_input());
|
||||
let response = input_handle.await.unwrap();
|
||||
command_tx
|
||||
let tx_res = command_tx
|
||||
.send(Message {
|
||||
source: Destination::Console,
|
||||
destination: Destination::Console,
|
||||
content: response.trim().to_string(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
.await;
|
||||
if tx_res.is_ok() {
|
||||
tx_res.unwrap();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
"DONE" => {
|
||||
break;
|
||||
|
||||
@@ -321,7 +321,7 @@ pub fn new_project(
|
||||
"upcoming_notes" => {
|
||||
notes_path = arg.path.unwrap();
|
||||
}
|
||||
"template" => {
|
||||
"templatebox" => {
|
||||
template_box = arg.string.unwrap();
|
||||
}
|
||||
_ => {}
|
||||
@@ -498,9 +498,10 @@ pub fn promote_project(
|
||||
content: projects_string,
|
||||
};
|
||||
tx.blocking_send(table_message).unwrap();
|
||||
let (gotten_name, mut rx) = prompt_interactive(rx, tx.clone(), "project to promote?");
|
||||
let (gotten_name, rx) = prompt_interactive(rx, tx.clone(), "project to promote?");
|
||||
let selection: usize = gotten_name.parse().unwrap();
|
||||
project = format!("{}", &projects[selection].name);
|
||||
deinitialize_interactive(tx.clone());
|
||||
}
|
||||
for mut existing_project in projects {
|
||||
if existing_project.name == project {
|
||||
@@ -519,7 +520,6 @@ pub fn promote_project(
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
deinitialize_interactive(tx.clone());
|
||||
}
|
||||
|
||||
pub fn remove_project(args: Option<Vec<ToolArgument>>) -> String {
|
||||
@@ -710,7 +710,7 @@ pub fn prompt_interactive(
|
||||
|
||||
pub fn deinitialize_interactive(tx: Sender<Message>) {
|
||||
tx.blocking_send(Message {
|
||||
source: Destination::Console,
|
||||
source: Destination::Control,
|
||||
destination: Destination::Console,
|
||||
content: String::from("noninteractive"),
|
||||
})
|
||||
|
||||
@@ -2,9 +2,13 @@ use colored::Colorize;
|
||||
use std::{
|
||||
fs::{File, OpenOptions, copy, create_dir_all, remove_dir_all, remove_file},
|
||||
io::Write,
|
||||
ops::Index,
|
||||
path::PathBuf,
|
||||
process::Command,
|
||||
slice::Windows,
|
||||
};
|
||||
use term_size::dimensions_stdout;
|
||||
use tokio::sync::OwnedMappedMutexGuard;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
@@ -158,6 +162,8 @@ impl Project {
|
||||
notes_template.push("phishing");
|
||||
} else if self.name.contains("webapp") {
|
||||
notes_template.push("webapp");
|
||||
} else {
|
||||
notes_template.push("external");
|
||||
}
|
||||
let walkdir = WalkDir::new(¬es_template);
|
||||
for res in walkdir {
|
||||
|
||||
Reference in New Issue
Block a user