Prepare for Lockfile saving; Clean up.
This commit is contained in:
28
src/cli.rs
28
src/cli.rs
@@ -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
1
src/lock.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub struct LockFile {}
|
||||
Reference in New Issue
Block a user