Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/xcrs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Android tools use `adb` from `ANDROID_SDK_ROOT`, `ANDROID_HOME`, the standard
Android SDK locations, or `PATH`. Connect a device with USB debugging enabled
and authorize the host before selecting it with `device_select`.

For Android accessibility-tree inspection and semantic `ui_tap`, install the
optional [XCRS AndroidKit](../../docs/androidkit.md) companion runner. Raw adb
actions remain available without it.

The same automation profile is available from the full smbCloud CLI:

```sh
Expand Down
50 changes: 49 additions & 1 deletion crates/xcrs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use clap::{Parser, Subcommand};
use std::path::PathBuf;
use xcrs::{IosAppTest, XcodeCommandLineTools};
use xcrs::{AndroidDebugBridge, AndroidKit, IosAppTest, XcodeCommandLineTools};

#[derive(Debug, Parser)]
#[command(name = "xcrs")]
Expand All @@ -19,6 +19,8 @@ struct Cli {
enum Commands {
#[command(subcommand)]
Simulator(SimulatorCommand),
#[command(subcommand)]
AndroidKit(AndroidKitCommand),
IosAppTest {
#[arg(long, conflicts_with = "simulator_udid")]
simulator_name: Option<String>,
Expand All @@ -35,6 +37,30 @@ enum Commands {
},
}

#[derive(Debug, Subcommand)]
enum AndroidKitCommand {
Install {
#[arg(long)]
serial: String,
#[arg(long)]
apk: PathBuf,
},
Start {
#[arg(long)]
serial: String,
},
Status {
#[arg(long)]
serial: String,
#[arg(long)]
json: bool,
},
Stop {
#[arg(long)]
serial: String,
},
}

#[derive(Debug, Subcommand)]
enum SimulatorCommand {
Find {
Expand Down Expand Up @@ -63,6 +89,28 @@ async fn main() -> Result<()> {
let tools = XcodeCommandLineTools::new();

match command {
Commands::AndroidKit(AndroidKitCommand::Install { serial, apk }) => {
AndroidDebugBridge::new().install_androidkit(&serial, &apk)?;
println!("Installed XCRS AndroidKit on {serial}");
}
Commands::AndroidKit(AndroidKitCommand::Start { serial }) => {
AndroidDebugBridge::new().start_androidkit(&serial).await?;
println!("Started XCRS AndroidKit on {serial}");
}
Commands::AndroidKit(AndroidKitCommand::Status { serial, json }) => {
let info = AndroidKit::new()
.call(serial.clone(), "device.info", serde_json::json!({}))
.await?;
if json {
println!("{}", serde_json::to_string_pretty(&info)?);
} else {
println!("XCRS AndroidKit is ready on {serial}");
}
}
Commands::AndroidKit(AndroidKitCommand::Stop { serial }) => {
AndroidDebugBridge::new().stop_androidkit(&serial)?;
println!("Stopped XCRS AndroidKit on {serial}");
}
Commands::Simulator(SimulatorCommand::Find { name, json }) => {
let simulator = tools.simctl().find_simulator_by_name(&name)?;
if json {
Expand Down
Loading
Loading