From 0841f38cb5dd7c89715c5c4823675c499df15d6e Mon Sep 17 00:00:00 2001 From: pyro57000 Date: Fri, 14 Nov 2025 17:08:34 -0600 Subject: [PATCH] fixed the issues when I moved the structs to the lib file --- src/cli.rs | 13 ++++++------- src/commands.rs | 11 ++++++----- src/lib.rs | 26 +++++++++++++------------- src/main.rs | 8 ++++---- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 5047c1c..16d897e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,17 +1,16 @@ -use std::io::Read; -use std::path::PathBuf; -use tokio::sync::mpsc::{Receiver, Sender, channel}; - -use crate::Message; use crate::commands; use crate::commands::ToolArgument; use crate::commands::ToolCommand; +use crate::lib::Message; use crate::load_projects; use crate::load_settings; use crate::network; use crate::print_error; -use crate::{Destination, Project, get_user_input, lib::Table, print_success}; +use crate::{get_user_input, lib::Destination, lib::Project, lib::Table, print_success}; +use std::io::Read; +use std::path::PathBuf; use tokio; +use tokio::sync::mpsc::{Receiver, Sender, channel}; pub async fn rec_message(mut rx: Receiver) { let mut display = true; @@ -23,7 +22,7 @@ pub async fn rec_message(mut rx: Receiver) { display = true; } if display { - println!("command?"); + println!("\n\ncommand?"); display = false; } } diff --git a/src/commands.rs b/src/commands.rs index f684609..99dfe41 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,6 +1,6 @@ -use crate::Destination; -use crate::Message; -use crate::Project; +use crate::lib::Destination; +use crate::lib::Message; +use crate::lib::Project; use crate::lib::Table; use crate::print_error; use crate::print_success; @@ -158,7 +158,6 @@ pub fn new_project(args: Option>) -> String { &project_path.display().to_string() ); } - let conf_file = file_create_res.unwrap(); files_path.push(&name); notes_path.push(&name); let files_dir_res = create_dir_all(&files_path); @@ -182,5 +181,7 @@ pub fn new_project(args: Option>) -> String { new_project.current = false; new_project.boxname = format!("{}_{}", template_box, name); save_project(&new_project, &project_path); - return String::from("Success!"); + print_success("folder structure and config file created successfully!"); + println!("setting up default notes..."); + return new_project.generate_default_notes(&config_path); } diff --git a/src/lib.rs b/src/lib.rs index 1501101..af03744 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,9 +6,9 @@ use walkdir::WalkDir; #[derive(Default, Clone)] pub struct Table { - columns: Vec, - headers: String, - data: Vec, + pub columns: Vec, + pub headers: String, + pub data: Vec, } impl Table { @@ -112,15 +112,15 @@ impl Table { } pub struct Server { - address: String, - id: usize, + pub address: String, + pub id: usize, } #[derive(Clone)] pub struct Message { - source: Destination, - destination: Destination, - content: String, + pub source: Destination, + pub destination: Destination, + pub content: String, } #[derive(Clone, PartialEq)] @@ -132,11 +132,11 @@ pub enum Destination { #[derive(Default, Clone)] pub struct Project { - name: String, - files: PathBuf, - notes: PathBuf, - current: bool, - boxname: String, + pub name: String, + pub files: PathBuf, + pub notes: PathBuf, + pub current: bool, + pub boxname: String, } impl Project { diff --git a/src/main.rs b/src/main.rs index dacdfd7..50c9620 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ pub fn get_user_input(prompt: &str) -> String { return response.trim().to_string(); } -pub fn load_projects(path: &PathBuf, display: bool) -> Vec { +pub fn load_projects(path: &PathBuf, display: bool) -> Vec { let mut projects_path = path.clone(); projects_path.pop(); projects_path.push("projects"); @@ -95,7 +95,7 @@ pub fn load_projects(path: &PathBuf, display: bool) -> Vec { let mut projects = Vec::new(); for res in project_dir { if res.is_ok() { - let mut new_project = Project::default(); + let mut new_project = lib::Project::default(); let entry = res.unwrap(); let file_name = entry.file_name().to_string_lossy().to_string(); if file_name.contains(".conf") { @@ -152,7 +152,7 @@ pub fn load_projects(path: &PathBuf, display: bool) -> Vec { return projects; } -pub fn save_project(project: &Project, config_path: &PathBuf) { +pub fn save_project(project: &lib::Project, config_path: &PathBuf) { let mut conf_open_options = OpenOptions::new(); if config_path.exists() { conf_open_options.append(true); @@ -313,7 +313,7 @@ async fn main() { let rx_rex = main_rx.try_recv(); if rx_rex.is_ok() { let message = rx_rex.unwrap(); - if message.destination == Destination::Control { + if message.destination == lib::Destination::Control { match message.content.as_str() { "exit" => { input_handle.abort();