Skip to main content

polyhorn_cli/ios/commands/
mod.rs

1//! iOS-specific implementations of Polyhorn CLI commands.
2
3mod run;
4mod test;
5
6pub use run::run;
7pub use test::test;
8
9use dialoguer::{theme::ColorfulTheme, Select};
10use simctl::DeviceQuery;
11
12fn select_device(devices: &[simctl::Device]) -> simctl::Device {
13    let mut devices = devices
14        .iter()
15        .available()
16        .filter(|device| device.name.starts_with("iPhone") || device.name.starts_with("iPad"))
17        .collect::<Vec<_>>();
18
19    let selections = devices
20        .iter()
21        .map(|device| {
22            device.name.to_owned()
23                + match device.state {
24                    simctl::list::DeviceState::Booted => " [booted]",
25                    _ => "",
26                }
27        })
28        .collect::<Vec<_>>();
29
30    let selection = Select::with_theme(&ColorfulTheme::default())
31        .with_prompt("Select your device")
32        .default(0)
33        .items(&selections[..])
34        .interact()
35        .unwrap();
36
37    devices.remove(selection).clone()
38}