Merge pull request #40 from DeterminateSystems/hoverbear/ds-430-plan-ux-refinement

Refine plan subcommand UX
This commit is contained in:
Ana Hobden 2022-11-09 08:47:05 -08:00 committed by GitHub
commit b123bbf285
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,19 +9,19 @@ use crate::cli::CommandExecute;
/// Plan an install that can be repeated on an identical host later
#[derive(Debug, Parser)]
#[command(multicall = true)]
#[command(args_conflicts_with_subcommands = true, arg_required_else_help = true)]
pub struct Plan {
#[clap(subcommand)]
pub planner: Option<BuiltinPlanner>,
#[clap(env = "HARMONIC_PLAN")]
pub plan: PathBuf,
pub output: PathBuf,
}
#[async_trait::async_trait]
impl CommandExecute for Plan {
#[tracing::instrument(skip_all, fields())]
async fn execute(self) -> eyre::Result<ExitCode> {
let Self { planner, plan } = self;
let Self { planner, output } = self;
let planner = match planner {
Some(planner) => planner,
@ -33,7 +33,7 @@ impl CommandExecute for Plan {
let install_plan = planner.plan().await.map_err(|e| eyre::eyre!(e))?;
let json = serde_json::to_string_pretty(&install_plan)?;
tokio::fs::write(plan, json)
tokio::fs::write(output, json)
.await
.wrap_err("Writing plan")?;