fixed the issues when I moved the structs to the lib file

This commit is contained in:
pyro57000
2025-11-14 17:08:34 -06:00
parent 1a72bcee98
commit 0841f38cb5
4 changed files with 29 additions and 29 deletions

View File

@@ -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;
use crate::commands::ToolArgument; use crate::commands::ToolArgument;
use crate::commands::ToolCommand; use crate::commands::ToolCommand;
use crate::lib::Message;
use crate::load_projects; use crate::load_projects;
use crate::load_settings; use crate::load_settings;
use crate::network; use crate::network;
use crate::print_error; 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;
use tokio::sync::mpsc::{Receiver, Sender, channel};
pub async fn rec_message(mut rx: Receiver<Message>) { pub async fn rec_message(mut rx: Receiver<Message>) {
let mut display = true; let mut display = true;
@@ -23,7 +22,7 @@ pub async fn rec_message(mut rx: Receiver<Message>) {
display = true; display = true;
} }
if display { if display {
println!("command?"); println!("\n\ncommand?");
display = false; display = false;
} }
} }

View File

@@ -1,6 +1,6 @@
use crate::Destination; use crate::lib::Destination;
use crate::Message; use crate::lib::Message;
use crate::Project; use crate::lib::Project;
use crate::lib::Table; use crate::lib::Table;
use crate::print_error; use crate::print_error;
use crate::print_success; use crate::print_success;
@@ -158,7 +158,6 @@ pub fn new_project(args: Option<Vec<ToolArgument>>) -> String {
&project_path.display().to_string() &project_path.display().to_string()
); );
} }
let conf_file = file_create_res.unwrap();
files_path.push(&name); files_path.push(&name);
notes_path.push(&name); notes_path.push(&name);
let files_dir_res = create_dir_all(&files_path); let files_dir_res = create_dir_all(&files_path);
@@ -182,5 +181,7 @@ pub fn new_project(args: Option<Vec<ToolArgument>>) -> String {
new_project.current = false; new_project.current = false;
new_project.boxname = format!("{}_{}", template_box, name); new_project.boxname = format!("{}_{}", template_box, name);
save_project(&new_project, &project_path); 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);
} }

View File

@@ -6,9 +6,9 @@ use walkdir::WalkDir;
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct Table { pub struct Table {
columns: Vec<usize>, pub columns: Vec<usize>,
headers: String, pub headers: String,
data: Vec<String>, pub data: Vec<String>,
} }
impl Table { impl Table {
@@ -112,15 +112,15 @@ impl Table {
} }
pub struct Server { pub struct Server {
address: String, pub address: String,
id: usize, pub id: usize,
} }
#[derive(Clone)] #[derive(Clone)]
pub struct Message { pub struct Message {
source: Destination, pub source: Destination,
destination: Destination, pub destination: Destination,
content: String, pub content: String,
} }
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
@@ -132,11 +132,11 @@ pub enum Destination {
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct Project { pub struct Project {
name: String, pub name: String,
files: PathBuf, pub files: PathBuf,
notes: PathBuf, pub notes: PathBuf,
current: bool, pub current: bool,
boxname: String, pub boxname: String,
} }
impl Project { impl Project {

View File

@@ -79,7 +79,7 @@ pub fn get_user_input(prompt: &str) -> String {
return response.trim().to_string(); return response.trim().to_string();
} }
pub fn load_projects(path: &PathBuf, display: bool) -> Vec<Project> { pub fn load_projects(path: &PathBuf, display: bool) -> Vec<lib::Project> {
let mut projects_path = path.clone(); let mut projects_path = path.clone();
projects_path.pop(); projects_path.pop();
projects_path.push("projects"); projects_path.push("projects");
@@ -95,7 +95,7 @@ pub fn load_projects(path: &PathBuf, display: bool) -> Vec<Project> {
let mut projects = Vec::new(); let mut projects = Vec::new();
for res in project_dir { for res in project_dir {
if res.is_ok() { if res.is_ok() {
let mut new_project = Project::default(); let mut new_project = lib::Project::default();
let entry = res.unwrap(); let entry = res.unwrap();
let file_name = entry.file_name().to_string_lossy().to_string(); let file_name = entry.file_name().to_string_lossy().to_string();
if file_name.contains(".conf") { if file_name.contains(".conf") {
@@ -152,7 +152,7 @@ pub fn load_projects(path: &PathBuf, display: bool) -> Vec<Project> {
return projects; 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(); let mut conf_open_options = OpenOptions::new();
if config_path.exists() { if config_path.exists() {
conf_open_options.append(true); conf_open_options.append(true);
@@ -313,7 +313,7 @@ async fn main() {
let rx_rex = main_rx.try_recv(); let rx_rex = main_rx.try_recv();
if rx_rex.is_ok() { if rx_rex.is_ok() {
let message = rx_rex.unwrap(); let message = rx_rex.unwrap();
if message.destination == Destination::Control { if message.destination == lib::Destination::Control {
match message.content.as_str() { match message.content.as_str() {
"exit" => { "exit" => {
input_handle.abort(); input_handle.abort();