refactor: fix clippy warnings
This commit is contained in:
+11
-11
@@ -42,20 +42,20 @@ fn handle_deploy(cli: &Cli, args: &DeployArgs, cfg: &config::Config) -> Result<(
|
||||
|
||||
let project = &cfg.projects[name];
|
||||
|
||||
deploy(&cli, &name, project)
|
||||
deploy(cli, name, project)
|
||||
}
|
||||
|
||||
fn handle_list(path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
println!("Config: {}", config::display(&path));
|
||||
println!("Config: {}", config::display(path));
|
||||
println!("Configured projects:");
|
||||
for name in cfg.projects.keys() {
|
||||
println!(" - {name}");
|
||||
}
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_list_servers(path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
println!("config: {}", config::display(&path));
|
||||
println!("config: {}", config::display(path));
|
||||
println!("configured servers:");
|
||||
for (name, server) in &cfg.servers {
|
||||
let mut line = format!(" - {name} {}", server.host);
|
||||
@@ -67,11 +67,11 @@ fn handle_list_servers(path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
}
|
||||
println!("{line}");
|
||||
}
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_pick(cli: &Cli, path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
let name = match pick_project(&cfg)? {
|
||||
let name = match pick_project(cfg)? {
|
||||
Some(name) => name,
|
||||
None => return Ok(()),
|
||||
};
|
||||
@@ -81,7 +81,7 @@ fn handle_pick(cli: &Cli, path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
.get(&name)
|
||||
.with_context(|| format!("project '{name}' not found in {}", path.display()))?;
|
||||
|
||||
deploy(&cli, &name, project)
|
||||
deploy(cli, &name, project)
|
||||
}
|
||||
|
||||
fn handle_default(path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
@@ -100,7 +100,7 @@ fn handle_default(path: &Path, cfg: &config::Config) -> Result<()> {
|
||||
}
|
||||
|
||||
fn deploy(cli: &Cli, name: &str, project: &Project) -> Result<()> {
|
||||
deploy::deploy(&name, project, cli.dry_run)
|
||||
deploy::deploy(name, project, cli.dry_run)
|
||||
}
|
||||
|
||||
fn run(cli: &Cli) -> Result<()> {
|
||||
@@ -108,8 +108,8 @@ fn run(cli: &Cli) -> Result<()> {
|
||||
let cfg = config::load(&path)?;
|
||||
|
||||
match &cli.command {
|
||||
Some(Commands::Deploy(args)) => handle_deploy(&cli, args, &cfg),
|
||||
Some(Commands::Pick) => handle_pick(&cli, &path, &cfg),
|
||||
Some(Commands::Deploy(args)) => handle_deploy(cli, args, &cfg),
|
||||
Some(Commands::Pick) => handle_pick(cli, &path, &cfg),
|
||||
Some(Commands::List) => handle_list(&path, &cfg),
|
||||
Some(Commands::ListServers) => handle_list_servers(&path, &cfg),
|
||||
None => handle_default(&path, &cfg),
|
||||
@@ -141,7 +141,7 @@ fn pick_project(cfg: &config::Config) -> Result<Option<String>> {
|
||||
|
||||
fn get_project_name_by_cwd(cfg: &Config) -> Result<&str> {
|
||||
let cwd = std::env::current_dir().context("cannot determine current directory")?;
|
||||
match config::find_by_cwd(&cfg, &cwd) {
|
||||
match config::find_by_cwd(cfg, &cwd) {
|
||||
Some(name) => Ok(name),
|
||||
None => bail!("no project found in {}", cwd.display()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user