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

Method run_remote

atomic-cli/src/commands/view/list.rs:116–166  ·  view source on GitHub ↗

List views on a remote repository. `remote_arg` is the raw `--remote` value: empty means "use the default remote", otherwise it is a configured remote name or a URL.

(&self, remote_arg: &str)

Source from the content-addressed store, hash-verified

114 /// `remote_arg` is the raw `--remote` value: empty means "use the default
115 /// remote", otherwise it is a configured remote name or a URL.
116 fn run_remote(&self, remote_arg: &str) -> CliResult<()> {
117 let repo_root = find_repository_root()?;
118 let repo = Repository::open(&repo_root).map_err(|e| match e {
119 atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound {
120 searched_path: path.into(),
121 },
122 other => CliError::Repository(other),
123 })?;
124
125 // Resolve the remote name and URL.
126 let (remote_name, remote_url) = if remote_arg.is_empty() {
127 repo.get_default_remote()
128 .map(|(name, entry)| (name, entry.url))
129 .map_err(CliError::Repository)?
130 } else if remote_arg.contains("://") {
131 (remote_arg.to_string(), remote_arg.to_string())
132 } else {
133 let entry = repo
134 .get_remote(remote_arg)
135 .map_err(|_| CliError::RemoteNotFound {
136 name: remote_arg.to_string(),
137 })?;
138 (remote_arg.to_string(), entry.url)
139 };
140
141 println!(
142 "Views on {} ({})",
143 style_view(&remote_name),
144 hint(&remote_url)
145 );
146
147 let rt = tokio::runtime::Runtime::new().map_err(|e| {
148 CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {}", e))
149 })?;
150
151 let views = rt.block_on(async {
152 let config = HttpRemoteConfig::new()
153 .with_timeout(Duration::from_secs(DEFAULT_TIMEOUT_SECS))
154 .danger_accept_invalid_certs(self.insecure);
155 let config = attach_identity(config, &remote_url, self.identity.as_deref()).await;
156 let remote = HttpRemote::with_config(&remote_url, config)
157 .map_err(|e| CliError::remote_error(e.to_string(), Some(remote_url.clone())))?;
158 remote
159 .list_views()
160 .await
161 .map_err(|e| CliError::remote_error(e.to_string(), Some(remote_url.clone())))
162 })?;
163
164 self.print_remote_views(&views);
165 Ok(())
166 }
167
168 /// Render the remote view listing.
169 fn print_remote_views(&self, views: &[RemoteViewInfo]) {

Callers 1

runMethod · 0.80

Calls 12

find_repository_rootFunction · 0.85
RepositoryClass · 0.85
attach_identityFunction · 0.85
get_default_remoteMethod · 0.80
print_remote_viewsMethod · 0.80
is_emptyMethod · 0.45
containsMethod · 0.45
get_remoteMethod · 0.45
with_timeoutMethod · 0.45
cloneMethod · 0.45
list_viewsMethod · 0.45

Tested by

no test coverage detected