sweet_cli/rsx/rsx_command.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;
use sweet::prelude::*;
/**
Welcome to the sweet rsx preprocessor!
this command will create a mirror of each file in the given directory,
but with all rsx! macros split into html, css and rust.
*/
#[derive(Debug, Parser)]
pub struct RsxCommand {
// The path to search
path: PathBuf,
/// Output to stdout instead of out dir
#[arg(long)]
dry: bool,
/// Output directory
#[arg(short, long, default_value = "./rsx")]
// 1000 is the most gracious
out_dir: String,
}
impl RsxCommand {
pub fn run(self) -> Result<()> {
self.for_each_file()?;
Ok(())
}
fn for_each_file(&self) -> Result<()> {
for file in ReadDir::files_recursive(&self.path)? {
println!("{}", file.display());
}
Ok(())
}
}