wrote some more stuff

This commit is contained in:
pyro57000
2025-12-31 10:23:37 -06:00
parent 921a2f5923
commit 5a84102138
5 changed files with 76 additions and 8 deletions

33
Cargo.lock generated
View File

@@ -437,6 +437,16 @@ dependencies = [
"unicode-ident", "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]] [[package]]
name = "tetanus_client" name = "tetanus_client"
version = "0.1.0" version = "0.1.0"
@@ -446,6 +456,7 @@ dependencies = [
"colored", "colored",
"dns-lookup", "dns-lookup",
"num_cpus", "num_cpus",
"term_size",
"tokio", "tokio",
"walkdir", "walkdir",
] ]
@@ -528,6 +539,22 @@ version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" 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]] [[package]]
name = "winapi-util" name = "winapi-util"
version = "0.1.11" version = "0.1.11"
@@ -537,6 +564,12 @@ dependencies = [
"windows-sys 0.61.2", "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]] [[package]]
name = "windows-link" name = "windows-link"
version = "0.2.1" version = "0.2.1"

View File

@@ -9,5 +9,6 @@ clap = { version = "4.5.51", features = ["derive"] }
colored = "3.0.0" colored = "3.0.0"
dns-lookup = "3.0.1" dns-lookup = "3.0.1"
num_cpus = "1.17.0" num_cpus = "1.17.0"
term_size = "0.3.2"
tokio = { version = "1.48.0", features = ["full"] } tokio = { version = "1.48.0", features = ["full"] }
walkdir = "2.5.0" walkdir = "2.5.0"

View File

@@ -1,6 +1,6 @@
use crate::{ use crate::{
commands::{ToolArgument, build_args, build_tools}, commands::{ToolArgument, build_args, build_tools},
lib::{Destination, Message, Project}, lib::{self, Destination, Message, Project},
load_projects, load_settings, print_error, print_success, load_projects, load_settings, print_error, print_success,
}; };
use std::{path::PathBuf, thread::sleep, time::Duration}; use std::{path::PathBuf, thread::sleep, time::Duration};
@@ -161,6 +161,30 @@ pub async fn cli(
}; };
main_tx.send(message).await.unwrap(); main_tx.send(message).await.unwrap();
break; 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 valid_command = false;
let mut command_to_run = tool_commands[0].clone(); let mut command_to_run = tool_commands[0].clone();
@@ -271,14 +295,18 @@ pub async fn cli(
"PROMPT" => { "PROMPT" => {
let input_handle = tokio::spawn(console_user_input()); let input_handle = tokio::spawn(console_user_input());
let response = input_handle.await.unwrap(); let response = input_handle.await.unwrap();
command_tx let tx_res = command_tx
.send(Message { .send(Message {
source: Destination::Console, source: Destination::Console,
destination: Destination::Console, destination: Destination::Console,
content: response.trim().to_string(), content: response.trim().to_string(),
}) })
.await .await;
.unwrap(); if tx_res.is_ok() {
tx_res.unwrap();
} else {
break;
}
} }
"DONE" => { "DONE" => {
break; break;

View File

@@ -321,7 +321,7 @@ pub fn new_project(
"upcoming_notes" => { "upcoming_notes" => {
notes_path = arg.path.unwrap(); notes_path = arg.path.unwrap();
} }
"template" => { "templatebox" => {
template_box = arg.string.unwrap(); template_box = arg.string.unwrap();
} }
_ => {} _ => {}
@@ -498,9 +498,10 @@ pub fn promote_project(
content: projects_string, content: projects_string,
}; };
tx.blocking_send(table_message).unwrap(); 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(); let selection: usize = gotten_name.parse().unwrap();
project = format!("{}", &projects[selection].name); project = format!("{}", &projects[selection].name);
deinitialize_interactive(tx.clone());
} }
for mut existing_project in projects { for mut existing_project in projects {
if existing_project.name == project { if existing_project.name == project {
@@ -519,7 +520,6 @@ pub fn promote_project(
.unwrap(); .unwrap();
} }
} }
deinitialize_interactive(tx.clone());
} }
pub fn remove_project(args: Option<Vec<ToolArgument>>) -> String { pub fn remove_project(args: Option<Vec<ToolArgument>>) -> String {
@@ -710,7 +710,7 @@ pub fn prompt_interactive(
pub fn deinitialize_interactive(tx: Sender<Message>) { pub fn deinitialize_interactive(tx: Sender<Message>) {
tx.blocking_send(Message { tx.blocking_send(Message {
source: Destination::Console, source: Destination::Control,
destination: Destination::Console, destination: Destination::Console,
content: String::from("noninteractive"), content: String::from("noninteractive"),
}) })

View File

@@ -2,9 +2,13 @@ use colored::Colorize;
use std::{ use std::{
fs::{File, OpenOptions, copy, create_dir_all, remove_dir_all, remove_file}, fs::{File, OpenOptions, copy, create_dir_all, remove_dir_all, remove_file},
io::Write, io::Write,
ops::Index,
path::PathBuf, path::PathBuf,
process::Command, process::Command,
slice::Windows,
}; };
use term_size::dimensions_stdout;
use tokio::sync::OwnedMappedMutexGuard;
use walkdir::WalkDir; use walkdir::WalkDir;
#[derive(Default, Clone)] #[derive(Default, Clone)]
@@ -158,6 +162,8 @@ impl Project {
notes_template.push("phishing"); notes_template.push("phishing");
} else if self.name.contains("webapp") { } else if self.name.contains("webapp") {
notes_template.push("webapp"); notes_template.push("webapp");
} else {
notes_template.push("external");
} }
let walkdir = WalkDir::new(&notes_template); let walkdir = WalkDir::new(&notes_template);
for res in walkdir { for res in walkdir {