Add repo rename command
This commit is contained in:
parent
357de970ee
commit
3390526522
4 changed files with 32 additions and 3 deletions
24
gdn-cli/src/commands/repo/rename.rs
Normal file
24
gdn-cli/src/commands/repo/rename.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use clap::Parser;
|
||||
|
||||
use crate::Environment;
|
||||
|
||||
/// Rename an existing repository.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Command {
|
||||
repo: String,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
pub fn run(self, env: &Environment) -> anyhow::Result<()> {
|
||||
let data = gdn::data::open_and_migrate(env.data_dir.clone())?;
|
||||
let state = gdn::data::load_state(&data)?;
|
||||
let Some(id) = state.resolve_repo_identifier(&self.repo) else {
|
||||
println!("No repo found for identifier {}.", self.repo);
|
||||
return Ok(());
|
||||
};
|
||||
gdn::data::rename_repo(&data, id, self.name.clone())?;
|
||||
println!("Renamed repo {} ({id}) to {}.", self.repo, self.name);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue