added a url for the obsidian notes of the current

project, and to get the vault name from the user
at install.
This commit is contained in:
pyro57000
2025-04-09 10:42:00 -05:00
parent 012ba517ab
commit 5bfa645b3d
3 changed files with 32 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::env::home_dir; use std::env::home_dir;
use std::fs::{File, create_dir_all, remove_dir_all}; use std::fs::{File, create_dir_all, remove_dir_all};
use std::io::Read; use std::io::{read_to_string, Read};
use std::io::Write; use std::io::Write;
use std::io::stdin; use std::io::stdin;
use std::io::copy; use std::io::copy;
@@ -30,6 +30,7 @@ pub fn install(config_path: &PathBuf){
let upcoming_projects = PathBuf::from(get_user_input("path to store your upcomming projects?")); let upcoming_projects = PathBuf::from(get_user_input("path to store your upcomming projects?"));
let upcoming_notes = PathBuf::from(get_user_input("path to store your upcomming project notes?")); let upcoming_notes = PathBuf::from(get_user_input("path to store your upcomming project notes?"));
let tools = PathBuf::from(get_user_input("path where you store your custom tools (like from github and places)?")); let tools = PathBuf::from(get_user_input("path where you store your custom tools (like from github and places)?"));
let mut vault_name = String::new();
let folders = vec![&current_projects, &current_notes, &upcoming_projects, &upcoming_notes, &tools]; let folders = vec![&current_projects, &current_notes, &upcoming_projects, &upcoming_notes, &tools];
let mut config_folder_path: PathBuf = config_path.clone(); let mut config_folder_path: PathBuf = config_path.clone();
config_folder_path.pop(); config_folder_path.pop();
@@ -170,6 +171,11 @@ pub fn install(config_path: &PathBuf){
terminal = format!("konsole --profile {}", profile_name); terminal = format!("konsole --profile {}", profile_name);
} }
} }
println!("many of the fuctions of this tool assume you're using obsidian or some other markdown editor for note taking");
let obsidian_used = get_user_input("do you use obsidian for your notes?");
if obsidian_used.to_lowercase().contains("y"){
vault_name = get_user_input("the name of the vault you're going to use?");
}
let configuration_string = format!(" let configuration_string = format!("
Project_files:{} Project_files:{}
Project_notes:{} Project_notes:{}
@@ -182,8 +188,9 @@ cracking_rig:{}
rockyou_location:{} rockyou_location:{}
rule_location:{} rule_location:{}
pass_file:{} pass_file:{}
fingerprint:{}" fingerprint:{}
, &current_projects.display(), &current_notes.display(), &tools.display(), &upcoming_projects.display(), &upcoming_notes.display(), &template_box_name, &terminal, cracking_rig, rockyou, rule, &password_path.display(), fingerprint); vault_name:{}"
, &current_projects.display(), &current_notes.display(), &tools.display(), &upcoming_projects.display(), &upcoming_notes.display(), &template_box_name, &terminal, cracking_rig, rockyou, rule, &password_path.display(), fingerprint, &vault_name);
println!("cool everything, all folders and settings have been entered, now let's save this to a config file..."); println!("cool everything, all folders and settings have been entered, now let's save this to a config file...");
thread::sleep(Duration::from_secs(3)); thread::sleep(Duration::from_secs(3));
let mut config_file_res = File::create_new(config_path); let mut config_file_res = File::create_new(config_path);

View File

@@ -94,6 +94,7 @@ fn main() {
let mut upcoming_notes = PathBuf::new(); let mut upcoming_notes = PathBuf::new();
let mut pass_spray_file = PathBuf::new(); let mut pass_spray_file = PathBuf::new();
let mut fingerprint = false; let mut fingerprint = false;
let mut vault_name = String::new();
println!("\nconfig already generated\nloading config file...\n"); println!("\nconfig already generated\nloading config file...\n");
let settings_string = fs::read_to_string(&config_path).expect("error reading config file"); let settings_string = fs::read_to_string(&config_path).expect("error reading config file");
let settings: Vec<&str> = settings_string.split("\n").collect(); let settings: Vec<&str> = settings_string.split("\n").collect();
@@ -113,6 +114,7 @@ fn main() {
"rule_location" => rule = setting_vec[1].trim_end().to_owned(), "rule_location" => rule = setting_vec[1].trim_end().to_owned(),
"pass_file"=> pass_spray_file.push(setting_vec[1]), "pass_file"=> pass_spray_file.push(setting_vec[1]),
"fingerprint" => {if setting_vec[1].contains("y"){fingerprint = true}}, "fingerprint" => {if setting_vec[1].contains("y"){fingerprint = true}},
"vault_name" => vault_name = setting_vec[1].trim_end().to_owned(),
_ => println!("error unknown setting: {}", setting_vec[0]) _ => println!("error unknown setting: {}", setting_vec[0])
} }
} }
@@ -132,5 +134,5 @@ fn main() {
println!("Enter to start main menu"); println!("Enter to start main menu");
let mut enter = String::new(); let mut enter = String::new();
std::io::stdin().read_line(&mut enter).unwrap(); std::io::stdin().read_line(&mut enter).unwrap();
menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule, &upcoming_files, &upcoming_notes, &pass_spray_file, fingerprint); menu::main_menu(projects, config_path, &project_base_folder, &project_base_notes, &tools_folder, box_template, terminal_command, cracking_rig, rockyou, rule, &upcoming_files, &upcoming_notes, &pass_spray_file, fingerprint, vault_name);
} }

View File

@@ -31,12 +31,27 @@ fn get_active_project(projects: &Vec<Project>) -> &Project{
return active_project return active_project
} }
pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String, cracking_rig: String, rockyou: String, rule: String, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf, fingerprint: bool){ pub fn main_menu(mut projects: Vec<Project>, config_path: PathBuf, base_files: &PathBuf, base_notes: &PathBuf, tools_dir: &PathBuf, boxtemplate: String, terminal: String, cracking_rig: String, rockyou: String, rule: String, upcoming_files: &PathBuf, upcoming_notes: &PathBuf, password_spray_file: &PathBuf, fingerprint: bool, vault_name: String){
let mut loopize = true; let mut loopize = true;
let mut new_id = next_project_id(&config_path); let mut new_id = next_project_id(&config_path);
let mut threads = Vec::new(); let mut threads = Vec::new();
loop { loop {
let active_project = get_active_project(&projects); let active_project = get_active_project(&projects);
let mut notes_folder_string = format!("{}", &active_project.notes_folder.display());
let mut obsidian_folder_vec = PathBuf::new();
let mut reached_vault_folder = false;
for folder in notes_folder_string.split("/").collect::<Vec<&str>>(){
if !folder.contains(&vault_name){
reached_vault_folder = true;
obsidian_folder_vec.push(folder);
}
else{
if reached_vault_folder{
obsidian_folder_vec.push(folder);
}
}
}
let obsidian_uri = format!("obsidian://open?vault={}&file={}", vault_name, obsidian_folder_vec.display().to_string().replace("/", "%2F"));
let mut response = String::new(); let mut response = String::new();
let now = Local::now(); let now = Local::now();
let month = now.month(); let month = now.month();
@@ -104,11 +119,12 @@ base prject folder: {}
upcoming project folder: {} upcoming project folder: {}
Current Project: {} {} Current Project: {} {}
Working Folder: {} Working Folder: {}
Notes Folder: {} Obsidian_uri: {}
Box Name: {} Box Name: {}
Terminal Command: {} Terminal Command: {}
Current Season: {} Current Season: {}
Year: {} Year: {}
General Notes: {}
Main Menu: Main Menu:
1 .) Show Active Project 1 .) Show Active Project
@@ -138,7 +154,7 @@ Year: {}
25.) Parse GatherContacts output file 25.) Parse GatherContacts output file
26.) prune unused distroboxes (free up system storage) 26.) prune unused distroboxes (free up system storage)
27.) Quit Application 27.) Quit Application
\n",&base_files.display(), &upcoming_files.display(), active_project.customer, active_project.project_name, active_project.files_folder.display(), active_project.notes_folder.display(), active_project.boxname, terminal, season, year); \n",&base_files.display(), &upcoming_files.display(), active_project.customer, active_project.project_name, active_project.files_folder.display(), active_project.notes_folder.display(), active_project.boxname, terminal, season, year, &obsidian_uri);
std::io::stdin().read_line(&mut response).expect("error getting menu input"); std::io::stdin().read_line(&mut response).expect("error getting menu input");
clear().expect("error clearing screen"); clear().expect("error clearing screen");
match response.as_str().trim_end(){ match response.as_str().trim_end(){