mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-08 03:10:26 +00:00
simplify: pass CommandContext to runs archive/rm helpers
`run_bulk` and `remove_from` took separate `json: bool` + `printer` parameters. Thread the context through instead and pull json/printer out of it inside the helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c87e282f8c
commit
80a36d1fca
2 changed files with 13 additions and 37 deletions
|
|
@ -3,7 +3,6 @@ use anyhow::{Result, bail};
|
|||
use super::short_run_id;
|
||||
use crate::args::{RunsArchiveArgs, RunsUnarchiveArgs};
|
||||
use crate::command_context::CommandContext;
|
||||
use crate::server_client;
|
||||
use crate::shared::print_json_pretty;
|
||||
|
||||
pub(crate) async fn archive_command(
|
||||
|
|
@ -11,14 +10,7 @@ pub(crate) async fn archive_command(
|
|||
base_ctx: &CommandContext,
|
||||
) -> Result<()> {
|
||||
let ctx = base_ctx.with_target(&args.server)?;
|
||||
run_bulk(
|
||||
Action::Archive,
|
||||
&args.runs,
|
||||
ctx.server().await?.as_ref(),
|
||||
ctx.json_output(),
|
||||
ctx.printer(),
|
||||
)
|
||||
.await
|
||||
run_bulk(Action::Archive, &args.runs, &ctx).await
|
||||
}
|
||||
|
||||
pub(crate) async fn unarchive_command(
|
||||
|
|
@ -26,14 +18,7 @@ pub(crate) async fn unarchive_command(
|
|||
base_ctx: &CommandContext,
|
||||
) -> Result<()> {
|
||||
let ctx = base_ctx.with_target(&args.server)?;
|
||||
run_bulk(
|
||||
Action::Unarchive,
|
||||
&args.runs,
|
||||
ctx.server().await?.as_ref(),
|
||||
ctx.json_output(),
|
||||
ctx.printer(),
|
||||
)
|
||||
.await
|
||||
run_bulk(Action::Unarchive, &args.runs, &ctx).await
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
|
@ -55,13 +40,11 @@ impl Action {
|
|||
}
|
||||
}
|
||||
|
||||
async fn run_bulk(
|
||||
action: Action,
|
||||
identifiers: &[String],
|
||||
client: &server_client::Client,
|
||||
json: bool,
|
||||
printer: fabro_util::printer::Printer,
|
||||
) -> Result<()> {
|
||||
async fn run_bulk(action: Action, identifiers: &[String], ctx: &CommandContext) -> Result<()> {
|
||||
let client = ctx.server().await?;
|
||||
let client = client.as_ref();
|
||||
let json = ctx.json_output();
|
||||
let printer = ctx.printer();
|
||||
let mut had_errors = false;
|
||||
let mut changed = Vec::new();
|
||||
let mut errors = Vec::new();
|
||||
|
|
|
|||
|
|
@ -8,21 +8,14 @@ use crate::shared::print_json_pretty;
|
|||
|
||||
pub(crate) async fn remove_command(args: &RunsRemoveArgs, base_ctx: &CommandContext) -> Result<()> {
|
||||
let ctx = base_ctx.with_target(&args.server)?;
|
||||
remove_from(
|
||||
args,
|
||||
ctx.server().await?.as_ref(),
|
||||
ctx.json_output(),
|
||||
ctx.printer(),
|
||||
)
|
||||
.await
|
||||
remove_from(args, &ctx).await
|
||||
}
|
||||
|
||||
async fn remove_from(
|
||||
args: &RunsRemoveArgs,
|
||||
client: &server_client::Client,
|
||||
json: bool,
|
||||
printer: fabro_util::printer::Printer,
|
||||
) -> Result<()> {
|
||||
async fn remove_from(args: &RunsRemoveArgs, ctx: &CommandContext) -> Result<()> {
|
||||
let client = ctx.server().await?;
|
||||
let client = client.as_ref();
|
||||
let json = ctx.json_output();
|
||||
let printer = ctx.printer();
|
||||
let mut had_errors = false;
|
||||
let mut removed = Vec::new();
|
||||
let mut errors = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue