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
49 changes: 12 additions & 37 deletions src/cli/release.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::runtime::{
InstallRuntimeFromOfficialReleaseOptions, OfficialRuntimePrepareAction, RuntimeService,
};
use crate::runtime::{InstallRuntimeFromOfficialReleaseOptions, RuntimeService};

use super::{Cli, render};

Expand Down Expand Up @@ -112,40 +110,17 @@ impl Cli {
"release install uses the canonical runtime name \"{runtime_name}\" for this selector"
));
}
if let Some(code) = self.ensure_official_release_host_ready(Some(profile), json_flag)? {
return Ok(code);
}

let (meta, action) =
self.with_progress(format!("Installing runtime {runtime_name}"), || {
self.runtime_service().prepare_official_openclaw_runtime(
InstallRuntimeFromOfficialReleaseOptions {
name: runtime_name.clone(),
version,
channel,
description,
force,
},
)
})?;

if json_flag {
self.print_json(&meta)?;
return Ok(0);
}

self.stdout_lines(match action {
OfficialRuntimePrepareAction::Installed => {
render::runtime::runtime_installed(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Reused => {
render::runtime::runtime_reused(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Updated => {
render::runtime::runtime_updated(&meta, profile, &self.command_example())
}
});
Ok(0)
self.install_official_runtime(
InstallRuntimeFromOfficialReleaseOptions {
name: runtime_name,
version,
channel,
description,
force,
},
json_flag,
profile,
)
}

pub(super) fn dispatch_release_command(
Expand Down
82 changes: 47 additions & 35 deletions src/cli/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::runtime::{
OfficialRuntimePrepareAction, RuntimeService, UpdateRuntimeFromReleaseOptions,
};

use super::render::RenderProfile;
use super::{Cli, render};

impl Cli {
Expand Down Expand Up @@ -224,41 +225,17 @@ impl Cli {
);
}
let name = resolve_official_name()?;
if let Some(code) =
self.ensure_official_release_host_ready(Some(profile), json_flag)?
{
return Ok(code);
}
let (meta, action) =
self.with_progress(format!("Installing runtime {name}"), || {
self.runtime_service().prepare_official_openclaw_runtime(
InstallRuntimeFromOfficialReleaseOptions {
name: name.clone(),
version,
channel,
description,
force,
},
)
})?;

if json_flag {
self.print_json(&meta)?;
return Ok(0);
}

self.stdout_lines(match action {
OfficialRuntimePrepareAction::Installed => {
render::runtime::runtime_installed(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Reused => {
render::runtime::runtime_reused(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Updated => {
render::runtime::runtime_updated(&meta, profile, &self.command_example())
}
});
return Ok(0);
return self.install_official_runtime(
InstallRuntimeFromOfficialReleaseOptions {
name,
version,
channel,
description,
force,
},
json_flag,
profile,
);
}
(None, None, None) => {
return Err(
Expand All @@ -282,6 +259,41 @@ impl Cli {
Ok(0)
}

pub(super) fn install_official_runtime(
&self,
options: InstallRuntimeFromOfficialReleaseOptions,
json_flag: bool,
profile: RenderProfile,
) -> Result<i32, String> {
if let Some(code) = self.ensure_official_release_host_ready(Some(profile), json_flag)? {
return Ok(code);
}

let (meta, action) =
self.with_progress(format!("Installing runtime {}", options.name), || {
self.runtime_service()
.prepare_official_openclaw_runtime(options)
})?;

if json_flag {
self.print_json(&meta)?;
return Ok(0);
}

self.stdout_lines(match action {
OfficialRuntimePrepareAction::Installed => {
render::runtime::runtime_installed(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Reused => {
render::runtime::runtime_reused(&meta, profile, &self.command_example())
}
OfficialRuntimePrepareAction::Updated => {
render::runtime::runtime_updated(&meta, profile, &self.command_example())
}
});
Ok(0)
}

pub(super) fn handle_runtime_build_local(&self, args: Vec<String>) -> Result<i32, String> {
let (args, json_flag, profile) =
self.consume_human_output_flags(args, "runtime build-local")?;
Expand Down
Loading