Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 committed Nov 13, 2024
1 parent 788bb4b commit 5a87065
Show file tree
Hide file tree
Showing 6 changed files with 415 additions and 98 deletions.
12 changes: 7 additions & 5 deletions src/file/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use std::{
path::PathBuf,
};

use crate::model::command;

#[derive(Debug, Serialize, Deserialize)]
struct Histories {
history: Vec<History>,
}

impl Histories {
fn from(histories: Vec<(PathBuf, Vec<String>)>) -> Self {
fn from(histories: Vec<(PathBuf, Vec<command::Command>)>) -> Self {
let mut result: Vec<History> = vec![];
for h in histories {
result.push(History {
Expand All @@ -28,13 +30,13 @@ impl Histories {
#[serde(rename_all = "kebab-case")]
struct History {
path: String,
executed_targets: Vec<String>,
executed_targets: Vec<command::Command>,
}

pub fn parse_history(content: String) -> Result<Vec<(PathBuf, Vec<String>)>> {
pub fn parse_history(content: String) -> Result<Vec<(PathBuf, Vec<command::Command>)>> {
let histories: Histories = toml::from_str(&content)?;

let mut result: Vec<(PathBuf, Vec<String>)> = Vec::new();
let mut result: Vec<(PathBuf, Vec<command::Command>)> = Vec::new();

for history in histories.history {
result.push((PathBuf::from(history.path), history.executed_targets));
Expand All @@ -46,7 +48,7 @@ pub fn parse_history(content: String) -> Result<Vec<(PathBuf, Vec<String>)>> {
pub fn store_history(
history_directory_path: PathBuf,
history_file_name: String,
histories_tuple: Vec<(PathBuf, Vec<String>)>,
histories_tuple: Vec<(PathBuf, Vec<command::Command>)>,
) -> Result<()> {
let histories = Histories::from(histories_tuple);

Expand Down
4 changes: 3 additions & 1 deletion src/model/command.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use serde::{Deserialize, Serialize};
use std::{fmt, path::PathBuf};

use super::runner_type;

#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Command {
pub runner_type: runner_type::RunnerType,
pub name: String,
Expand Down
Loading

0 comments on commit 5a87065

Please sign in to comment.