forked from lix-project/lix-installer
Refine plan subcommand UX
This commit is contained in:
parent
6678b1cdee
commit
00ffe96aae
|
@ -9,19 +9,19 @@ use crate::cli::CommandExecute;
|
||||||
|
|
||||||
/// Plan an install that can be repeated on an identical host later
|
/// Plan an install that can be repeated on an identical host later
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(multicall = true)]
|
#[command(args_conflicts_with_subcommands = true, arg_required_else_help = true)]
|
||||||
pub struct Plan {
|
pub struct Plan {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub planner: Option<BuiltinPlanner>,
|
pub planner: Option<BuiltinPlanner>,
|
||||||
#[clap(env = "HARMONIC_PLAN")]
|
#[clap(env = "HARMONIC_PLAN")]
|
||||||
pub plan: PathBuf,
|
pub output: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl CommandExecute for Plan {
|
impl CommandExecute for Plan {
|
||||||
#[tracing::instrument(skip_all, fields())]
|
#[tracing::instrument(skip_all, fields())]
|
||||||
async fn execute(self) -> eyre::Result<ExitCode> {
|
async fn execute(self) -> eyre::Result<ExitCode> {
|
||||||
let Self { planner, plan } = self;
|
let Self { planner, output } = self;
|
||||||
|
|
||||||
let planner = match planner {
|
let planner = match planner {
|
||||||
Some(planner) => 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 install_plan = planner.plan().await.map_err(|e| eyre::eyre!(e))?;
|
||||||
|
|
||||||
let json = serde_json::to_string_pretty(&install_plan)?;
|
let json = serde_json::to_string_pretty(&install_plan)?;
|
||||||
tokio::fs::write(plan, json)
|
tokio::fs::write(output, json)
|
||||||
.await
|
.await
|
||||||
.wrap_err("Writing plan")?;
|
.wrap_err("Writing plan")?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue