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

Method run

atomic-cli/src/commands/add.rs:416–548  ·  view source on GitHub ↗

Execute the add command. This method: 1. Finds and opens the repository 2. Collects files to add (from arguments or --all) 3. Adds each file to tracking 4. Prints the results # Errors Returns an error if: - No repository is found - A file doesn't exist - A file is inside .atomic/ - A database error occurs

(&self)

Source from the content-addressed store, hash-verified

414 /// - A file is inside .atomic/
415 /// - A database error occurs
416 fn run(&self) -> CliResult<()> {
417 if crate::commands::rpc::add(self)? {
418 return Ok(());
419 }
420
421 // Find the repository root
422 let repo_root = find_repository_root()?;
423
424 // Open the repository and retain its stable workspace boundary for all add work.
425 let mode = if self.dry_run {
426 WorkspaceTxnMode::Observe
427 } else {
428 WorkspaceTxnMode::Reconcile
429 };
430 let mut repo = if self.dry_run {
431 Repository::open_readonly(&repo_root)
432 } else {
433 Repository::open_for_workspace_transaction(&repo_root)
434 }
435 .map_err(|e| CliError::InvalidRepository {
436 reason: e.to_string(),
437 })?;
438 let workspace = enter_workspace(&mut repo, mode)?;
439 let working_copy = workspace.working_copy();
440
441 // Get tracking options
442 let mut options = self.get_tracking_options();
443 if self.dry_run {
444 options.dry_run = true;
445 }
446
447 // Collect files to add
448 let files_to_add: Vec<PathBuf> = if self.all {
449 self.collect_untracked_files(&repo, working_copy)?
450 } else {
451 self.files.iter().map(PathBuf::from).collect()
452 };
453
454 if files_to_add.is_empty() {
455 if self.all {
456 println!("{}", info("No untracked files to add"));
457 } else {
458 return Err(CliError::InvalidArgument {
459 message: "No files specified. Use 'atomic add <files>' or 'atomic add --all'"
460 .to_string(),
461 });
462 }
463 return Ok(());
464 }
465
466 // Add each file and collect stats
467 let mut total_stats = AggregateStats::new();
468 let mut had_errors = false;
469
470 for path in &files_to_add {
471 let path_str = path.to_string_lossy();
472
473 match self.add_path(&repo, working_copy, &path_str, &options) {

Calls 15

find_repository_rootFunction · 0.85
print_warningFunction · 0.85
print_blankFunction · 0.85
print_hintFunction · 0.85
get_tracking_optionsMethod · 0.80
shim_workspace_activeMethod · 0.80
print_resultsMethod · 0.80
addFunction · 0.70
enter_workspaceFunction · 0.70
working_copyMethod · 0.45