`atomic view list` over ListViews — every local form (`--remote` is the scope-out remote surface). The wire's ViewInfo carries each view's own/inherited change-count split and head state, so the versioned JSON document renders client-side with the same JsonView shape the local body emits; the plain form keeps its metadata rendering.
(args: &super::view::List)
| 3011 | /// document renders client-side with the same JsonView shape the local |
| 3012 | /// body emits; the plain form keeps its metadata rendering. |
| 3013 | pub fn view_list(args: &super::view::List) -> CliResult<bool> { |
| 3014 | if args.remote.is_some() { |
| 3015 | return Ok(false); // the remote listing (scope-out remote surface) |
| 3016 | } |
| 3017 | // `view list` is #207's explicit registration/migration entry for a new |
| 3018 | // linked worktree or an older native repository. Migrate before opening |
| 3019 | // the service session; ListViews itself keeps its read-only contract. |
| 3020 | if let Ok(root) = super::find_repository_root() { |
| 3021 | match atomic_repository::Repository::open_readonly_wait( |
| 3022 | &root, |
| 3023 | atomic_repository::database_lock_wait(), |
| 3024 | ) { |
| 3025 | Ok(_) => {} |
| 3026 | Err(atomic_repository::RepositoryError::WorkingCopyMigrationRequired { .. }) => { |
| 3027 | drop(atomic_repository::Repository::open(&root).map_err(CliError::Repository)?); |
| 3028 | } |
| 3029 | Err(error) => { |
| 3030 | // Inspect the schema without requiring its completion. Do not |
| 3031 | // turn arbitrary query errors into a writable recovery open. |
| 3032 | let needs_path_migration = |
| 3033 | atomic_repository::Repository::open_readonly_for_native_repair(&root) |
| 3034 | .and_then(|repo| repo.path_claim_migration_required()) |
| 3035 | .unwrap_or(false); |
| 3036 | if !needs_path_migration { |
| 3037 | return Err(CliError::Repository(error)); |
| 3038 | } |
| 3039 | drop(atomic_repository::Repository::open(&root).map_err(CliError::Repository)?); |
| 3040 | } |
| 3041 | } |
| 3042 | } |
| 3043 | let Some(session) = Service::open()? else { |
| 3044 | return Ok(false); |
| 3045 | }; |
| 3046 | let response = session.list_views(pb::ListViewsRequest { |
| 3047 | repository: Some(session.reference.clone()), |
| 3048 | include_details: false, |
| 3049 | })?; |
| 3050 | if args.json { |
| 3051 | let mut json_views = response |
| 3052 | .views |
| 3053 | .iter() |
| 3054 | .map(super::view::list::JsonView::from_wire) |
| 3055 | .collect::<Vec<_>>(); |
| 3056 | json_views.sort_by(|left, right| left.name.cmp(&right.name)); |
| 3057 | let current = response |
| 3058 | .views |
| 3059 | .iter() |
| 3060 | .find(|view| view.current) |
| 3061 | .map(|view| view.name.clone()); |
| 3062 | super::view::list::print_local_json(&json_views, current)?; |
| 3063 | return Ok(true); |
| 3064 | } |
| 3065 | let entries: Vec<super::view::list::ViewEntry> = response |
| 3066 | .views |
| 3067 | .iter() |
| 3068 | .map(super::view::list::ViewEntry::from_wire) |
| 3069 | .collect(); |
| 3070 |
no test coverage detected