Skip to content

Commit

Permalink
feat: ✨ Display information for the generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
AntwortEinesLebens committed Jan 31, 2025
1 parent e868146 commit 34ed2d0
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::commands::{
traces::{Trace, Traces, Traversable},
Runnable,
use crate::{
commands::{
traces::{Trace, Traces, Traversable},
Runnable,
},
displayer::Displayer,
};
use clap::Parser;
use console::{style, Emoji};
Expand Down Expand Up @@ -105,24 +108,43 @@ impl Display for Author {

impl Runnable for Generate {
fn run(&self) -> ExitCode {
let mut displayer: Displayer = Displayer::new();
displayer.loading("Checking the generation path validity");

let Ok(generation_exists) = self.generation.try_exists() else {
displayer.failure("Failed to check the existence of the generation path");

return ExitCode::FAILURE;
};

if !generation_exists || !self.generation.is_file() {
displayer.failure("The generation path does not exist or is not a file path");

return ExitCode::FAILURE;
}

displayer.success("The generation path is valid");
displayer.loading("Reading the generation file");

let Ok(file_content) = read_to_string(self.generation.clone()) else {
displayer.failure("Failed to read the generation file");

return ExitCode::FAILURE;
};

displayer.success("The generation file is read");
displayer.loading("Parsing the content");

let Ok(generation): Result<Generation, TomlError> = from_str(file_content.as_str()) else {
displayer.failure("Failed to parse the content");

return ExitCode::FAILURE;
};

displayer.success("The content is parsed");

println!(
"Generation metadata\n\
"\nGeneration metadata\n\
{}",
generation.metadata
);
Expand Down

0 comments on commit 34ed2d0

Please sign in to comment.