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

Method run

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

Source from the content-addressed store, hash-verified

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

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