Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Present ensured states in order.
Browse files Browse the repository at this point in the history
azriel91 committed Mar 24, 2023
1 parent a7b00ed commit af70c15
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions examples/app_cycle/src/cmds/env_deploy_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use futures::FutureExt;
use peace::{
cmd::scopes::SingleProfileSingleFlowView,
fmt::presentable::{Heading, HeadingLevel, ListNumbered},
rt::cmds::{sub::StatesSavedReadCmd, EnsureCmd},
rt_model::output::OutputWrite,
};
@@ -27,13 +29,44 @@ impl EnvDeployCmd {
StatesSavedReadCmd::exec(ctx).boxed_local()
})
.await?;
EnvCmd::run_and_present(output, false, |ctx| {
EnvCmd::run(output, true, |ctx| {
async move {
let states_saved_ref = &states_saved;
EnsureCmd::exec(ctx, states_saved_ref).await
let states_ensured = EnsureCmd::exec(ctx, states_saved_ref).await?;

let states_ensured_raw_map = &**states_ensured;

let SingleProfileSingleFlowView { output, flow, .. } = ctx.view();
let states_ensured_presentables = {
let states_ensured_presentables = flow
.graph()
.iter_insertion()
.map(|item_spec| {
let item_spec_id = item_spec.id();
match states_ensured_raw_map.get(item_spec_id) {
Some(state_ensured) => (item_spec_id, format!(": {state_ensured}")),
None => (item_spec_id, String::from(": <unknown>")),
}
})
.collect::<Vec<_>>();

ListNumbered::new(states_ensured_presentables)
};

output
.present(&(
Heading::new(HeadingLevel::Level1, "States Ensured"),
states_ensured_presentables,
"\n",
))
.await?;

Ok(())
}
.boxed_local()
})
.await
.await?;

Ok(())
}
}

0 comments on commit af70c15

Please sign in to comment.