MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / execute

Method execute

atomic-cli/src/commands/update.rs:537–578  ·  view source on GitHub ↗

Pure business logic. Returns an `UpdateOutcome`, or a `CliError::RemoteError` for network / GitHub failures. Caller decides exit code and presentation.

(&self)

Source from the content-addressed store, hash-verified

535 /// `CliError::RemoteError` for network / GitHub failures. Caller
536 /// decides exit code and presentation.
537 async fn execute(&self) -> CliResult<UpdateOutcome> {
538 let env = StdEnv;
539 let source = match std::env::current_exe() {
540 Ok(p) => detect_source(&p, &env),
541 Err(_) => InstallSource::Unknown,
542 };
543
544 let current = env!("CARGO_PKG_VERSION").to_string();
545 let latest_tag = fetch_latest(&env).await?;
546 let latest = latest_tag
547 .strip_prefix('v')
548 .unwrap_or(&latest_tag)
549 .to_string();
550
551 Ok(match (parse_version(&current), parse_version(&latest)) {
552 (Some(c), Some(l)) if c == l => UpdateOutcome::UpToDate { current, source },
553 (Some(c), Some(l)) if c > l => UpdateOutcome::AheadOfRelease {
554 current,
555 latest,
556 source,
557 },
558 (Some(_), Some(_)) => {
559 let drift = match &source {
560 InstallSource::OfficialInstaller {
561 recorded_version, ..
562 } if recorded_version != &current => Some(recorded_version.clone()),
563 _ => None,
564 };
565 UpdateOutcome::Outdated {
566 current,
567 latest,
568 source,
569 drift_manifest_version: drift,
570 }
571 }
572 _ => UpdateOutcome::UnknownVersion {
573 current,
574 latest,
575 source,
576 },
577 })
578 }
579}
580
581// Tests — inline because atomic-cli is a binary crate with no lib.rs,

Callers 1

runMethod · 0.45

Calls 4

detect_sourceFunction · 0.85
fetch_latestFunction · 0.85
parse_versionFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected