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::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<Message>) {
let mut display = true;
@@ -23,7 +22,7 @@ pub async fn rec_message(mut rx: Receiver<Message>) {
display = true;
}
if display {
println!("command?");
println!("\n\ncommand?");
display = false;
}
}

View File

@@ -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<Vec<ToolArgument>>) -> 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<Vec<ToolArgument>>) -> 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);
}

View File

@@ -6,9 +6,9 @@ use walkdir::WalkDir;
#[derive(Default, Clone)]
pub struct Table {
columns: Vec<usize>,
headers: String,
data: Vec<String>,
pub columns: Vec<usize>,
pub headers: String,
pub data: Vec<String>,
}
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 {

View File

@@ -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<Project> {
pub fn load_projects(path: &PathBuf, display: bool) -> Vec<lib::Project> {
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<Project> {
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<Project> {
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();