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

Method run

atomic-cli/src/commands/view/list.rs:560–649  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

558
559impl Command for List {
560 fn run(&self) -> CliResult<()> {
561 if crate::commands::rpc::view_list(self)? {
562 return Ok(());
563 }
564
565 // Remote listing takes over entirely when --remote is present.
566 if let Some(remote_arg) = &self.remote {
567 return self.run_remote(remote_arg);
568 }
569
570 // Find the repository
571 let repo_root = find_repository_root()?;
572 let repo = Repository::open(&repo_root).map_err(|e| match e {
573 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
574 searched_path: path.into(),
575 },
576 other => CliError::Repository(other),
577 })?;
578
579 // Get list of views
580 let views = repo.list_views().map_err(CliError::Repository)?;
581 let working_copy = repo
582 .require_working_copy_id()
583 .map_err(CliError::Repository)?;
584 let current = repo
585 .desired_view_name(working_copy)
586 .map_err(CliError::Repository)?;
587 let current = /* dev sync: desired view is authoritative for working-copy-aware repos */ current.clone();
588
589 if self.json {
590 let mut json_views = Vec::with_capacity(views.len());
591 for view in &views {
592 let info = repo.get_view_info(view).map_err(CliError::Repository)?;
593 json_views.push(JsonView::from_local(&info, *view == current));
594 }
595 json_views.sort_by(|left, right| left.name.cmp(&right.name));
596 return print_json(&JsonViewList {
597 schema_version: VIEW_LIST_JSON_SCHEMA_VERSION,
598 source: "local",
599 repository_root: Some(repo_root.to_string_lossy().into_owned()),
600 remote: None,
601 current_view: Some(current.to_string()),
602 views: json_views,
603 });
604 }
605
606 if views.is_empty() {
607 println!(
608 "{}",
609 hint("No views found. Use 'atomic view create <name>' to create one.")
610 );
611 return Ok(());
612 }
613
614 // Collect metadata for every view; fall back to name-only entries
615 // when info is unavailable so the names still render.
616 let entries: Vec<ViewEntry> = views
617 .iter()

Callers 5

test_list_default_viewFunction · 0.45
test_list_multiple_viewsFunction · 0.45
test_list_verboseFunction · 0.45
test_list_after_switchFunction · 0.45

Calls 15

view_listFunction · 0.85
find_repository_rootFunction · 0.85
openFunction · 0.85
RepositoryClass · 0.85
compute_visibilityFunction · 0.85
tree_orderFunction · 0.85
render_short_lineFunction · 0.85
render_lineFunction · 0.85
run_remoteMethod · 0.80
desired_view_nameMethod · 0.80
get_view_infoMethod · 0.80

Tested by 5

test_list_default_viewFunction · 0.36
test_list_multiple_viewsFunction · 0.36
test_list_verboseFunction · 0.36
test_list_after_switchFunction · 0.36