use std::path::PathBuf;
use crate::command::{
Executable,
build::{BuildConfig, build, lockfile::BuildLockfile},
};
#[derive(Debug, clap::Args)]
pub struct Update {
#[clap(value_name = "DATAFLOW")]
dataflow: PathBuf,
#[clap(long, action)]
offline: bool,
#[clap(long, action)]
dry_run: bool,
}
impl Executable for Update {
fn execute(self) -> eyre::Result<()> {
let lockfile_path = BuildLockfile::path_for_dataflow(&self.dataflow, None);
if !lockfile_path.exists() {
eyre::bail!(
"no lockfile at `{}` โ run `dora build --write-lockfile {}` first",
lockfile_path.display(),
self.dataflow.display()
);
}
build(BuildConfig {
dataflow: self.dataflow.to_string_lossy().into_owned(),
offline: self.offline,
write_lockfile: !self.dry_run,
lockfile_only: true,
..Default::default()
})?;
if self.dry_run {
println!("dry run โ lockfile not written");
} else {
println!("updated {}", lockfile_path.display());
}
Ok(())
}
}