mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-18 10:53:56 +01:00
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
use crate::cli::config::{read_config, write_config, CliConfig};
|
|
use clap::Args;
|
|
|
|
#[derive(Debug, Args)]
|
|
pub struct ScriptsRepoCommand {
|
|
/// The new repo URL to set as default, don't pass any value to check the current default repo
|
|
#[arg(index = 1, value_parser = crate::cli::parse_gix_url)]
|
|
repo: Option<gix::Url>,
|
|
|
|
/// Resets the default repo to the default value
|
|
#[arg(short, long, conflicts_with = "repo")]
|
|
reset: bool,
|
|
}
|
|
|
|
impl ScriptsRepoCommand {
|
|
pub fn run(self) -> anyhow::Result<()> {
|
|
let mut config = read_config()?;
|
|
|
|
let repo = if self.reset {
|
|
Some(CliConfig::default().scripts_repo)
|
|
} else {
|
|
self.repo
|
|
};
|
|
|
|
match repo {
|
|
Some(repo) => {
|
|
config.scripts_repo = repo.clone();
|
|
write_config(&config)?;
|
|
println!("scripts repo set to: {repo}");
|
|
}
|
|
None => {
|
|
println!("current scripts repo: {}", config.scripts_repo);
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|