pub fn cmd_edit(mana_dir: &Path, id: &str) -> Result<()>Expand description
Orchestrate the complete bn edit workflow for a unit.
The full edit workflow:
- Validate the unit ID format
- Find the unit file using discovery
- Load the current unit content as a backup
- Open the file in the user’s configured editor
- Load the edited content
- Validate and save with schema validation (updates timestamp)
- Rebuild the index to reflect changes
If validation fails, prompts user to retry, rollback, or abort. If editor subprocess fails, handles the error gracefully.
§Arguments
mana_dir- Path to the .mana directoryid- Unit ID to edit (e.g., “1”, “1.1”)
§Returns
- Ok(()) if edit is successful and saved
- Err if:
- Unit ID not found
- $EDITOR not set or editor not found
- Editor exits with non-zero status
- Validation fails and user chooses abort
- I/O or index rebuild fails
§Examples
ⓘ
cmd_edit(Path::new(".mana"), "1")?;