es_fluent_cli/commands/clean/
mod.rs1mod orphaned;
4
5use crate::commands::{
6 GenerationVerb, WorkspaceArgs, WorkspaceCrates, parallel_generate,
7 render_generation_results_with_dry_run,
8};
9use crate::core::{CliError, GenerationAction};
10use crate::utils::ui;
11use clap::Parser;
12
13use orphaned::clean_orphaned_files;
14
15#[derive(Parser)]
17pub struct CleanArgs {
18 #[command(flatten)]
19 pub workspace: WorkspaceArgs,
20
21 #[arg(long)]
23 pub all: bool,
24
25 #[arg(long)]
27 pub dry_run: bool,
28
29 #[arg(long)]
31 pub force_run: bool,
32
33 #[arg(long)]
37 pub orphaned: bool,
38}
39
40pub fn run_clean(args: CleanArgs) -> Result<(), CliError> {
42 let workspace = WorkspaceCrates::discover(args.workspace)?;
43
44 if !workspace.print_discovery(ui::print_header) {
45 return Ok(());
46 }
47
48 if args.orphaned {
50 return clean_orphaned_files(&workspace, args.all, args.dry_run);
51 }
52
53 let action = GenerationAction::Clean {
54 all_locales: args.all,
55 dry_run: args.dry_run,
56 };
57
58 let results = parallel_generate(
59 &workspace.workspace_info,
60 &workspace.valid,
61 &action,
62 args.force_run,
63 );
64 let has_errors =
65 render_generation_results_with_dry_run(&results, args.dry_run, GenerationVerb::Clean);
66
67 if has_errors {
68 std::process::exit(1);
69 }
70
71 Ok(())
72}