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

Method run

atomic-cli/src/commands/workspace/create.rs:72–124  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

70
71impl Command for WorkspaceCreate {
72 fn run(&self) -> CliResult<()> {
73 if self.name.is_empty() {
74 return Err(CliError::InvalidArgument {
75 message: "Workspace name is required.".to_string(),
76 });
77 }
78
79 let rt = tokio::runtime::Runtime::new().map_err(|e| {
80 CliError::Internal(anyhow::anyhow!("Failed to create async runtime: {}", e))
81 })?;
82
83 rt.block_on(async {
84 let client = build_client(self.org.as_deref(), None).await?;
85
86 let visibility = self.parse_visibility()?;
87
88 let req = CreateWorkspaceRequest {
89 name: self.name.clone(),
90 description: self.description.clone(),
91 visibility,
92 };
93
94 let ws = client.create_workspace(&req).await.map_err(remote_err)?;
95
96 print_success(&format!(
97 "Created workspace: {} (slug: {})",
98 ws.name, ws.slug
99 ));
100 println!();
101
102 let table = KeyValueTable::new()
103 .add("Name", &ws.name)
104 .add("Slug", &ws.slug)
105 .add("Visibility", ws.visibility.to_string())
106 .add("Created", crate::commands::format_timestamp(&ws.created_at));
107
108 println!("{}", table);
109
110 print_next_steps(&[
111 (
112 &format!("atomic workspace set {}", ws.slug),
113 "Set as your default workspace",
114 ),
115 (
116 "atomic project create <project-name>",
117 "Create a project in this workspace",
118 ),
119 ("atomic workspace list", "View all workspaces"),
120 ]);
121
122 Ok(())
123 })
124 }
125}
126
127#[cfg(test)]

Callers 1

empty_name_rejectedFunction · 0.45

Calls 9

build_clientFunction · 0.85
print_successFunction · 0.85
format_timestampFunction · 0.85
print_next_stepsFunction · 0.85
create_workspaceMethod · 0.80
is_emptyMethod · 0.45
parse_visibilityMethod · 0.45
cloneMethod · 0.45
addMethod · 0.45

Tested by 1

empty_name_rejectedFunction · 0.36