holodeck-simctl 0.10.0

A CLI and TUI companion for the iOS Simulator's simctl — boot, record, screenshot, and manage simulators
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use holodeck_core::models::{Simulator, SimulatorState};
use holodeck_services::SimulatorService;

/// Resolves `query` then asserts it's in `required_state`, mirroring the
/// Swift `SimulatorService.resolveInState(_:_:purpose:)` helper shared by
/// most subcommands.
pub async fn resolve_in_state(
    service: &SimulatorService,
    query: &str,
    required_state: SimulatorState,
    purpose: &str,
) -> anyhow::Result<Simulator> {
    let sim = service.resolve(query).await?;
    if sim.state != required_state {
        anyhow::bail!("{} is {}; {}.", sim.name, sim.state.raw_value(), purpose);
    }
    Ok(sim)
}