Skip to content

Commit

Permalink
wasm: add version to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaoboy committed Oct 19, 2024
1 parent 1c60a18 commit 5a67d30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions ansi2-wasm/src-ts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { to_svg, to_html, to_text, Theme } from "./wasm"
import { readFileSync, existsSync } from "node:fs"
import { optimize } from "svgo"
import { Mode } from "./wasm"
import { version } from "../package.json"

async function readToString() {
return new Promise<string>((resolve) => {
Expand Down Expand Up @@ -55,20 +56,21 @@ function getMode(s: string | undefined): Mode | undefined {
}

async function main() {
const input = await readToString()

program
.option("-f, --format [type]", "output format", "svg")
.option("-t, --theme [type]", "color theme", "vscode")
.option("-w, --width [type]", "width", undefined)
.option("--font [type]", "font", undefined)
.option("-m, --mode [type]", "mode", undefined)
.option("-c, --compress [type]", "compress", undefined)
.option("--light-bg [type]", "light-bg", undefined)
.option("--dark-bg [type]", "dark-bg", undefined)
.option("-f, --format [html, svg, text]", "output format", "svg")
.option("-t, --theme [vscode, ubuntu, vga, xterm]", "color theme", "vscode")
.option("-w, --width [number]", "width", undefined)
.option("--font [string]", "font", undefined)
.option("-m, --mode [dark, light]", "mode", undefined)
.option("-c, --compress [bool]", "compress", undefined)
.option("--light-bg [string eg.#FFFFFF]", "light-bg", undefined)
.option("--dark-bg [string eg.#000000]", "dark-bg", undefined)
.version(version)

program.parse()

const input = await readToString()

const options = program.opts()
const theme = getTheme(options.theme ?? "vscode")
const mode = getMode(options.mode)
Expand Down
3 changes: 2 additions & 1 deletion ansi2-wasm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"declarationMap": false,
"sourceMap": false
},
"include": ["src-ts"]
"include": ["src-ts"],
"exclude": ["src-ts/cli.ts"]
}

0 comments on commit 5a67d30

Please sign in to comment.