-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,31 @@ | ||
import { parseArgs } from "node:util"; | ||
import * as console from "node:console"; | ||
import { buildFlipForge } from "./build"; | ||
import { Command } from "commander"; | ||
import { version } from "../package.json"; | ||
import { buildFlipForge, type BuildOptions } from "./build"; | ||
|
||
function main() { | ||
const { values, positionals } = parseArgs({ | ||
strict: true, | ||
allowPositionals: true, | ||
options: { | ||
baseUrl: { | ||
type: "string", | ||
default: "", | ||
}, | ||
fullUrl: { | ||
type: "string", | ||
default: "http://localhost:8080", | ||
}, | ||
title: { | ||
type: "string", | ||
default: "", | ||
}, | ||
description: { | ||
type: "string", | ||
default: "", | ||
}, | ||
writeEnv: { | ||
type: "boolean", | ||
default: true, | ||
}, | ||
}, | ||
}); | ||
const program = new Command(); | ||
program | ||
.name("build-flip-forge") | ||
.description("Build flip forge site from cmd line") | ||
.version(version) | ||
.argument("<pdfPath>", "PDF File to build site from") | ||
.option("--base-url <value>", "Base url of the site", "") | ||
.option("--full-url <value>", "Full url of the site", "") | ||
.option("--title <value>", "Meta title of the site", "") | ||
.option("--description <value>", "Meta description for the site", "") | ||
.option("--write-env", "", false) | ||
.allowExcessArguments(false); | ||
program.parse(); | ||
|
||
if (positionals.length !== 1) { | ||
console.error("One file must be specified, got:", positionals); | ||
process.exit(1); | ||
} | ||
const [pdfPath] = program.processedArgs; | ||
const options = program.opts(); | ||
|
||
console.log(options); | ||
buildFlipForge({ | ||
pdfPath: positionals[0], | ||
...values, | ||
}); | ||
pdfPath, | ||
...options, | ||
} as BuildOptions); | ||
} | ||
|
||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters