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

Method run

atomic-cli/src/commands/update.rs:452–530  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

450
451impl Command for Update {
452 fn run(&self) -> CliResult<()> {
453 let rt = tokio::runtime::Runtime::new()
454 .map_err(|e| CliError::Internal(anyhow::anyhow!("tokio runtime: {e}")))?;
455
456 let outcome = rt.block_on(self.execute())?;
457
458 // block_on has returned: the runtime is dropped before we reach
459 // any std::process::exit calls below.
460
461 match outcome {
462 UpdateOutcome::UpToDate { current, .. } => {
463 print_success(&format!("You're on the latest release ({current})."));
464 Ok(())
465 }
466 UpdateOutcome::Outdated {
467 current,
468 latest,
469 source,
470 drift_manifest_version,
471 } => {
472 if self.check {
473 println!(
474 "Outdated: {current} -> {latest} (source: {})",
475 source.short_label()
476 );
477 std::process::exit(1);
478 }
479 let env = StdEnv;
480 let msg = format_upgrade_message(
481 &source,
482 &current,
483 &latest,
484 drift_manifest_version.as_deref(),
485 &env,
486 );
487 print!("{msg}");
488 Ok(())
489 }
490 UpdateOutcome::AheadOfRelease {
491 current,
492 latest,
493 source,
494 } => {
495 if self.check {
496 println!(
497 "Ahead of release: {current} > {latest} (source: {})",
498 source.short_label()
499 );
500 // Exit 0 — nothing to upgrade — but distinct status text
501 // so dev / pre-release users aren't told they're "on the
502 // latest release" when they're actually ahead of it.
503 return Ok(());
504 }
505 print_info(&format!(
506 "This binary is newer than the latest GitHub release.\n Current: {current}\n Latest release: {latest}"
507 ));
508 Ok(())
509 }

Callers

nothing calls this directly

Calls 6

print_successFunction · 0.85
format_upgrade_messageFunction · 0.85
print_infoFunction · 0.85
print_warningFunction · 0.85
print_hintFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected