From 17e19106c8410c31e7f6b28dceba27a00480c371 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 1 Feb 2025 01:14:44 +0100 Subject: [PATCH] add CLI --- .changeset/great-toes-remain.md | 5 +++++ README.md | 18 ++++++++++++++++++ src/cli/index.ts | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .changeset/great-toes-remain.md diff --git a/.changeset/great-toes-remain.md b/.changeset/great-toes-remain.md new file mode 100644 index 0000000..476544f --- /dev/null +++ b/.changeset/great-toes-remain.md @@ -0,0 +1,5 @@ +--- +"@beequeue/gmd": minor +--- + +Added a CLI diff --git a/README.md b/README.md index 4f3e171..7c9d0c6 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,24 @@ A library for parsing and serializing GMD files for the MT Framework engine, mor Largely based on the work in [onepiecefreak3/GMDConverter](https://github.com/onepiecefreak3/GMDConverter). +## Usage (CLI) + +```sh +pnpm install -g @beequeue/gmd +gmd --help +``` + +The input can be a file, directory, or glob pattern. + +By default the output will be written to the same directory as the input file. + +`--option` can be used to change this to a specific directory. + +```sh +gmd decode --output ./output path/to/files/**/*.gmd +gmd encode ./output/**/* +``` + ## Usage ```typescript diff --git a/src/cli/index.ts b/src/cli/index.ts index ecb3270..7d71dce 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -75,7 +75,9 @@ if (isGlob(input) || checkIfDir(input)) { let finish: APIBuilder if (checkIfDir(input)) { - finish = builder.filter((file) => file.endsWith(".gmd")).crawl(input) + finish = builder + .filter((file) => file.endsWith(command === "decode" ? ".gmd" : ".gmd.json")) + .crawl(input) } else { const { base, glob } = pico.scan(input) finish = builder.glob(glob).crawl(base)