aboutsummaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d4ae2f84..154e0c99 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -37,6 +37,7 @@ mod server_not_running;
mod spec;
mod status;
mod tab;
+mod target;
mod workspace;
mod worktree;
@@ -93,6 +94,10 @@ pub(super) fn print_read_response(response: &serde_json::Value) -> std::io::Resu
Ok(0)
}
+pub(crate) fn maybe_run_machine(args: &[String]) -> Option<std::io::Result<CommandOutcome>> {
+ target::maybe_run(args)
+}
+
pub fn maybe_run(args: &[String]) -> std::io::Result<CommandOutcome> {
let Some(command) = args.get(1).map(|arg| arg.as_str()) else {
return Ok(CommandOutcome::NotCli);
@@ -762,7 +767,7 @@ pub(super) fn send_ok_request(method: Method) -> std::io::Result<i32> {
}
pub(super) fn send_request(request: &Request) -> std::io::Result<serde_json::Value> {
- let client = ApiClient::local();
+ let client = target::api_client()?;
ensure_server_protocol_compatible(&client, &request.id)?;
client
.request_value(request)
@@ -770,7 +775,7 @@ pub(super) fn send_request(request: &Request) -> std::io::Result<serde_json::Val
}
pub(super) fn send_request_unchecked(request: &Request) -> std::io::Result<serde_json::Value> {
- let client = ApiClient::local();
+ let client = target::api_client()?;
client
.request_value(request)
.map_err(|err| map_server_not_running_or_io(err, &request.id, &client))
@@ -783,11 +788,9 @@ fn ensure_server_protocol_compatible(client: &ApiClient, request_id: &str) -> st
let server_protocol = status
.protocol
.ok_or_else(|| std::io::Error::other("server ping did not include a protocol version"))?;
- let Some(response) = protocol_guard::mismatch_response(
- request_id,
- server_protocol,
- &crate::session::active_restart_after_update_guidance(),
- ) else {
+ let Some(response) =
+ protocol_guard::mismatch_response(request_id, server_protocol, &target::restart_guidance())
+ else {
return Ok(());
};
@@ -834,6 +837,9 @@ fn map_server_not_running_or_io(
request_id: &str,
client: &ApiClient,
) -> std::io::Error {
+ if target::is_remote() {
+ return target::remote_error(api_client_error_to_io(err));
+ }
match err {
ApiClientError::Io(io_err) if server_not_running_error(&io_err) => {
server_not_running::reported_error(server_not_running::response(