wrote some more stuff
This commit is contained in:
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