Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cli/export/register.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -14,7 +15,10 @@ export const registerExport = (program: Command) => {
.command("export")
.description("Export tscircuit code to various formats")
.argument("<file>", "Path to the package file")
.option("-f, --format <format>", "Output format")
.option(
"-f, --format <format>",
`Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`,
)
.option("-o, --output <path>", "Output file path")
.option("--disable-parts-engine", "Disable the parts engine")
.action(
Expand Down
6 changes: 3 additions & 3 deletions lib/shared/export-snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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<ExportFormat, string> = {
json: ".circuit.json",
Expand Down Expand Up @@ -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)
}
Expand Down
Loading