From 4b585c8de2bc98e9ed5920537878e245aafe56d8 Mon Sep 17 00:00:00 2001 From: Severin Ibarluzea Date: Mon, 17 Nov 2025 14:52:01 -0800 Subject: [PATCH] Document export formats in help --- cli/export/register.ts | 6 +++++- lib/shared/export-snippet.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/export/register.ts b/cli/export/register.ts index 0b3c53f6..43cc429a 100644 --- a/cli/export/register.ts +++ b/cli/export/register.ts @@ -1,6 +1,7 @@ import type { Command } from "commander" import { exportSnippet } from "lib/shared/export-snippet" import type { ExportFormat } from "lib/shared/export-snippet" +import { ALLOWED_EXPORT_FORMATS } from "lib/shared/export-snippet" import { generateCircuitJson } from "lib/shared/generate-circuit-json" import { getSpiceWithPaddedSim } from "lib/shared/get-spice-with-sim" import { runSimulation } from "lib/eecircuit-engine/run-simulation" @@ -14,7 +15,10 @@ export const registerExport = (program: Command) => { .command("export") .description("Export tscircuit code to various formats") .argument("", "Path to the package file") - .option("-f, --format ", "Output format") + .option( + "-f, --format ", + `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`, + ) .option("-o, --output ", "Output file path") .option("--disable-parts-engine", "Disable the parts engine") .action( diff --git a/lib/shared/export-snippet.ts b/lib/shared/export-snippet.ts index b662ab51..aace62b4 100644 --- a/lib/shared/export-snippet.ts +++ b/lib/shared/export-snippet.ts @@ -18,7 +18,7 @@ import type { PlatformConfig } from "@tscircuit/props" const writeFileAsync = promisify(fs.writeFile) -const ALLOWED_FORMATS = [ +export const ALLOWED_EXPORT_FORMATS = [ "json", "circuit-json", "schematic-svg", @@ -33,7 +33,7 @@ const ALLOWED_FORMATS = [ "kicad_zip", ] as const -export type ExportFormat = (typeof ALLOWED_FORMATS)[number] +export type ExportFormat = (typeof ALLOWED_EXPORT_FORMATS)[number] const OUTPUT_EXTENSIONS: Record = { json: ".circuit.json", @@ -74,7 +74,7 @@ export const exportSnippet = async ({ onError = (message) => console.error(message), onSuccess = (result: unknown) => console.log(result), }: ExportOptions) => { - if (!ALLOWED_FORMATS.includes(format)) { + if (!ALLOWED_EXPORT_FORMATS.includes(format)) { onError(`Invalid format: ${format}`) return onExit(1) }