Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ edition = "2021"
crossterm = "0.27.0"
itertools = "0.13.0"
ratatui = "0.26.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
7 changes: 6 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{io, error, fs};
use std::io::Error;
use std::path::Path;
use crate::CronTask;
use serde_json;

struct TableColors {
buffer_bg: Color,
Expand Down Expand Up @@ -247,6 +248,10 @@ impl App {
let text: &str = "Hello, world!!!";
let crondata = &self.tasks;
_ = std::fs::write(path, text);
_ = std::fs::write(path2, crondata);
let json_string = serde_json::to_string_pretty(crondata)
.expect("Failed to serialize crondata to JSON"); // Handles the &Vec<CronTask> to String conversion

_ = std::fs::write(path2, json_string.as_bytes()) // Writes the String as bytes
.expect("Failed to write crondata to file");
}
}
6 changes: 4 additions & 2 deletions src/cron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use ratatui::widgets::{Block, Paragraph, Row, Table};
use crate::app::{App, CurrentTab, InputState};
use crate::ui::render_ui;

#[derive(Clone)]
// Add these two lines for serde
use serde::{Serialize, Deserialize};

#[derive(Clone, Serialize, Deserialize)] // Add Serialize and Deserialize here
pub struct CronTask {
pub minute: String,
pub hour: String,
Expand All @@ -29,4 +32,3 @@ impl CronTask {
}
//todo? find a way to formulate the cron task struct into a list / database vector OF cron tasks.
}