diff --git a/.changeset/pre.json b/.changeset/pre.json index 2694e7b..8d14a34 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -9,6 +9,7 @@ }, "changesets": [ "blue-dingos-exist", + "calm-data-flow", "crazy-berries-peel", "early-knives-sing", "forty-cows-brush", @@ -18,8 +19,13 @@ "hungry-emus-poke", "khaki-doodles-heal", "nasty-seas-learn", + "plain-names-land", + "quiet-bins-show", + "quiet-names-stay", + "sharp-flags-halt", "stale-socks-relax", "tired-trams-play", - "tired-webs-hunt" + "tired-webs-hunt", + "whole-args-pass" ] } diff --git a/bun.lock b/bun.lock index f141c98..48340cc 100644 --- a/bun.lock +++ b/bun.lock @@ -35,7 +35,7 @@ }, "packages/cli": { "name": "@gud/cli", - "version": "1.0.0-beta.7", + "version": "1.0.0-beta.8", "dependencies": { "@types/prompts": "^2.4.9", "cliui": "^8.0.1", diff --git a/examples/node-js/package.json b/examples/node-js/package.json index 8d64ca2..7478140 100644 --- a/examples/node-js/package.json +++ b/examples/node-js/package.json @@ -13,7 +13,7 @@ "prod": "node cli.js" }, "dependencies": { - "@gud/cli": "1.0.0-beta.7", + "@gud/cli": "1.0.0-beta.8", "@gud/cli-menu": "1.0.0-beta.5" } } diff --git a/examples/typescript/package.json b/examples/typescript/package.json index b042a4a..2f04bf9 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -17,7 +17,7 @@ "watch": "tsc --watch" }, "dependencies": { - "@gud/cli": "1.0.0-beta.7", + "@gud/cli": "1.0.0-beta.8", "@gud/cli-menu": "1.0.0-beta.5" }, "devDependencies": { diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index a0e7cf9..7606d4f 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,16 @@ # @gud/cli +## 1.0.0-beta.8 + +### Patch Changes + +- a7d101e: Added `setData()` to the command state to set the data without continuing to the next command, and an optional result type parameter to `fork()`. Fixed `beforeCommand` hooks' `setData()` not reaching the command handler, and `afterCommand` hooks receiving the command's input instead of its output; `afterCommand` hooks' `setData()` now also overrides the data when the command calls `next()` or `end()`. Documented that passing `undefined` to `next()` or `end()` keeps the current data and `null` clears it. +- e5b36fe: Fixed option values of commands with `isMiddleware: false` being resolved as subcommands, e.g., `hello --name Bob` failing with `Command "Bob" not found`. Leading options are now removed using the command's options config regardless of `isMiddleware`. +- f0e7af4: Fixed the help usage line showing a partial path to the executed script instead of the CLI name. The name defaults to the matching `bin` entry in the CLI's package.json, so it's correct when package managers install a shim instead of a symlink (pnpm, and npm or yarn on Windows), and falls back to the script's file name. It can also be set with the new `name` option on `run()` and `Context`, and the lookup is exported as `getBinName`. Also made `getHelp`, `plugin`, and `PluginError` runtime exports; they were previously exported as types only. +- 7a13c3f: Fixed arguments containing spaces being split apart when `run()` is given a command array (including the default `process.argv`), e.g., `--name "Bob Smith"` failing with `Command "Smith" not found`. `joinTokens()` now quotes tokens with spaces whenever there's more than one token, not only when it's given more than one argument. +- 1658940: Fixed subcommands being resolved from the wrong position when a leading option or option value matched the subcommand's name, e.g., `deploy --target run run` resolving `run` twice. `removeLeadingOptions()` now stops at the first argument that isn't an option or an option's value instead of searching for the next command. +- b860d92: Fixed quotes, escapes, and repeated spaces in arguments being lost (e.g., `--msg 'say "hi"'` becoming `say`) by passing arguments through resolution and parsing as an array instead of a command string. `Context` has a new `argv` property and accepts `argv` instead of `commandString`, resolved commands have `remainingArgv`, the `beforeResolve`, `beforeResolveNext`, and `beforeParse` hooks receive `argv`, and `resolveCommand()`, `context.resolveCommand()`, `context.parseCommand()`, and `removeLeadingOptions()` accept arrays. `ParseCommandFn` now receives `string | string[]`, and the CLI passes it arrays, so custom parse functions need to handle arrays; support for command strings will be removed in the next major version. `splitTokens()` now ignores repeated delimiters. + ## 1.0.0-beta.7 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 0a4a49a..ff7606f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@gud/cli", - "version": "1.0.0-beta.7", + "version": "1.0.0-beta.8", "description": "A framework for building flexible and extensible CLIs", "license": "Apache-2.0", "author": "ryan goree (https://github.com/ryangoree)",