(args: Vec<String>)
| 24 | const ASSET_MANIFEST: &str = "target/pglite-oxide/assets/manifest.json"; |
| 25 | |
| 26 | pub(crate) fn extensions(args: Vec<String>) -> Result<()> { |
| 27 | match args.first().map(String::as_str) { |
| 28 | Some("discover") => { |
| 29 | let catalog = discover_catalog()?; |
| 30 | validate_catalog(&catalog)?; |
| 31 | let text = serde_json::to_string_pretty(&catalog).context("serialize catalog")?; |
| 32 | if args.iter().any(|arg| arg == "--write") { |
| 33 | write_catalog(&text)?; |
| 34 | } else { |
| 35 | println!("{text}"); |
| 36 | } |
| 37 | Ok(()) |
| 38 | } |
| 39 | Some("generate") => { |
| 40 | let catalog = discover_catalog()?; |
| 41 | validate_catalog(&catalog)?; |
| 42 | let text = serde_json::to_string_pretty(&catalog).context("serialize catalog")?; |
| 43 | write_catalog(&text)?; |
| 44 | write_build_plan_files(&catalog)?; |
| 45 | write_generated_extension_api(&catalog)?; |
| 46 | Ok(()) |
| 47 | } |
| 48 | Some("build-plan") => { |
| 49 | let catalog = discover_catalog()?; |
| 50 | validate_catalog(&catalog)?; |
| 51 | if args.iter().any(|arg| arg == "--write") { |
| 52 | write_build_plan_files(&catalog) |
| 53 | } else if args.iter().any(|arg| arg == "--check") { |
| 54 | check_build_plan_file(true) |
| 55 | } else { |
| 56 | let plan = build_plan(&catalog)?; |
| 57 | println!( |
| 58 | "{}", |
| 59 | serde_json::to_string_pretty(&plan) |
| 60 | .context("serialize extension build plan")? |
| 61 | ); |
| 62 | Ok(()) |
| 63 | } |
| 64 | } |
| 65 | Some("check") => { |
| 66 | check_catalog_file(true)?; |
| 67 | check_build_plan_file(true) |
| 68 | } |
| 69 | Some(other) => bail!("unknown extensions subcommand: {other}"), |
| 70 | None => { |
| 71 | bail!( |
| 72 | "usage: cargo run -p xtask -- extensions <discover|generate|build-plan|check> [--write|--check]" |
| 73 | ) |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | pub(crate) fn check_catalog_file(strict: bool) -> Result<()> { |
| 79 | let catalog = discover_catalog()?; |
no test coverage detected