Prepare for Lockfile saving; Clean up.

This commit is contained in:
Olivia Brooks
2025-10-15 12:42:21 -04:00
parent eb0237792c
commit 5247a52497
4 changed files with 102 additions and 5 deletions

View File

@@ -8,11 +8,23 @@ pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(value_hint = clap::ValueHint::DirPath, default_value = format!("./target"))]
#[arg(value_hint = clap::ValueHint::DirPath, default_value = "./target")]
target_dir: PathBuf,
}
#[derive(Debug, Subcommand)]
impl Cli {
fn get_target_dir(&self) -> PathBuf {
match self.command.clone() {
Commands::Clean => self.target_dir.to_owned(),
Commands::Build { lockfile, .. } => lockfile.into(),
Commands::Refresh { lockfile, .. } => lockfile.into(),
Commands::Update { lockfile } => lockfile.into(),
_ => panic!("New cli::Commands variant not accounted for."),
}
}
}
#[derive(Debug, Subcommand, Clone, PartialEq)]
pub enum Commands {
#[command(arg_required_else_help = true)]
Build {
@@ -60,13 +72,13 @@ pub enum RefreshScope {
All, // Both of the above
}
#[derive(Debug, Args)]
#[derive(Debug, Args, Clone, PartialEq)]
pub struct LockfileAccess {
/// Path to blog root for batch updating.
#[arg(
long,
value_hint = clap::ValueHint::DirPath,
default_value = format!("./")
default_value = "./"
)]
post_tree: PathBuf,
@@ -75,7 +87,13 @@ pub struct LockfileAccess {
short,
long,
value_hint = clap::ValueHint::DirPath,
default_value = format!("cutinews.lock")
default_value = "cutinews.lock"
)]
lock_file: PathBuf,
}
impl Into<PathBuf> for LockfileAccess {
fn into(self) -> PathBuf {
return PathBuf::from(format!("{:?}{:?}", self.post_tree, self.lock_file));
}
}

1
src/lock.rs Normal file
View File

@@ -0,0 +1 @@
pub struct LockFile {}