版本发布 8
## Changes This release breaks quite a bit of stuff, but for a good cause! Goodbye `[]string` and hello to type safe structs! I've completed re-worked how positional arguments work, instead of getting the raw `[]string` passed to the `Run` method, I've introduced a mechanism for declaring *type-safe* structs describing the positional arguments, which are then inferred using generics and parsed similar to how flags already worked. As a result of this: - I've dropped the `cli.Allow` option and *all* the argument validators as this new mechanism is much better and allows you to define exactly what arguments you want and what types they are - The signature of the function provided to `cli.Run` has changed from `func(cmd *cli.Command, args []string) error` to `func(cmd *cli.Command) error` - Raw positional arguments can still be obtained using `cmd.Args()` - `cli.NoShortHand` is now `flag.NoShortHand` - `cli.FlagCount` is now `flag.Count` See the updated `README` and the updated examples for how to change your code to match the new behaviour. I've updated my projects that use this and the changes honestly aren't so bad ## :boom: Breaking Changes * Breaking: Completely rework how positional arguments are handled (#178) @FollowTheProcess * Breaking: Move FlagCount and Flaggable to a public flag package (#177) @FollowTheProcess ## :rocket: Features * Breaking: Completely rework how positional arguments are handled (#178) @FollowTheProcess * If a subcommand does not set a version, use the root command's version (#176) @FollowTheProcess ## :rotating_light: Testing * Bump up test coverage (#181) @FollowTheProcess ## :hammer: Refactoring * Centralise the tabwriter creation (#182) @FollowTheProcess * Migrate internal/flag to the new parse/format mechanisms (#180) @FollowTheProcess * Add new parse and format packages to reduce duplication (#179) @FollowTheProcess
## Changes ## :rocket: Features * Don't show empty slices as flag default values in help (#175) @FollowTheProcess * Tweak the title colour in help text (#173) @FollowTheProcess ## :package: Dependencies * Update module go.followtheprocess.codes/test to v1 (#174) @[renovate[bot]](https://github.com/apps/renovate)
## Changes * Update FollowTheProcess/ci action to v3 (#160) @[renovate[bot]](https://github.com/apps/renovate) * Configure Renovate (#157) @[renovate[bot]](https://github.com/apps/renovate) ## :rocket: Features * Migrate this project to the vanity URL (#162) @FollowTheProcess ## :construction_worker: Continuous Integration * Update golangci-lint config to v2 (#155) @FollowTheProcess ## :package: Dependencies * Bump github.com/FollowTheProcess/snapshot from 0.4.2 to 0.5.0 (#156) @[dependabot[bot]](https://github.com/apps/dependabot) * Bump github.com/FollowTheProcess/test from 0.20.3 to 0.21.0 (#154) @[dependabot[bot]](https://github.com/apps/dependabot) * Bump github.com/FollowTheProcess/test from 0.20.2 to 0.20.3 (#153) @[dependabot[bot]](https://github.com/apps/dependabot)
## Changes * Remove the ability to set a custom VersionFunc (#148) @FollowTheProcess ## :rocket: Features * Allow `Count` flags to be directly passed an argument e.g. `--verbosity=3` (#146) @FollowTheProcess * Align flag non-zero default values with the tabwriter (#142) @FollowTheProcess ## :beetle: Fixes * Remove unnecessary newline after examples (#150) @FollowTheProcess ## :racehorse: Performance * Pre-compute the size of the buffer to hold `--version` text (#152) @FollowTheProcess * Optimise help and usage buffer size (#149) @FollowTheProcess ## :rotating_light: Testing * Add `t.Parallel()` to all tests and subtests (#141) @FollowTheProcess ## :books: Documentation * Better document flaggable types as well as general usage (#147) @FollowTheProcess * Use charmbracelet/freeze to render the demo image (#144) @FollowTheProcess * Add an example of slice flags to the subcommands demo (#143) @FollowTheProcess ## :lipstick: Style * Remove unneeded t.Helper calls (#145) @FollowTheProcess ## :package: Dependencies * Update dependencies in go.mod (#151) @FollowTheProcess
## Changes * Tidy up some tests (#138) @FollowTheProcess ## :rocket: Features * Support `[]Flaggable` flags where multiple uses append to the underlying slice (#140) @FollowTheProcess ## :books: Documentation * Simplify the subcommand example code (#137) @FollowTheProcess ## :hammer: Refactoring * Refactor `internal/flag` for less pointer dereferencing (#139) @FollowTheProcess ## :lipstick: Style * Don't style the colon in help titles (#136) @FollowTheProcess
## Changes ## :rocket: Features * A flag with a non-zero default value will now show the default in the help (#133) @FollowTheProcess * Align the argument required/default specifier using tabwriter (#127) @FollowTheProcess ## :construction_worker: Continuous Integration * Update and refresh golangci-lint config (#130) @FollowTheProcess * Move to my new Go CI workflow (#124) @FollowTheProcess ## :books: Documentation * Tidy up some doc comments (#135) @FollowTheProcess * Include a `time.Duration` flag in the subcommands example (#129) @FollowTheProcess * Add gifs for all examples (#128) @FollowTheProcess * Change the theme and font of demo gifs (#126) @FollowTheProcess ## :hammer: Refactoring * Narrow `Flaggable` type constraint (#132) @FollowTheProcess ## :package: Dependencies * Bump github.com/FollowTheProcess/test from 0.20.1 to 0.20.2 (#131) @[dependabot[bot]](https://github.com/apps/dependabot) * Update test and snapshot (#125) @FollowTheProcess * Bump github.com/FollowTheProcess/test from 0.17.1 to 0.18.0 (#123) @[dependabot[bot]](https://github.com/apps/dependabot)
## Changes ## :boom: Breaking Changes * Replace `Arg` with `RequiredArg` and `OptionalArg` and update help text (#121) @FollowTheProcess ## :rocket: Features * Add a `cli.NoColour` option for disabling all colour/style (#122) @FollowTheProcess * Replace `Arg` with `RequiredArg` and `OptionalArg` and update help text (#121) @FollowTheProcess
## Changes ## :rocket: Features * `cli.Short` and `cli.Long` now strip leading and trailing whitespace (#120) @FollowTheProcess ## :beetle: Fixes * Fix an issue where cli.FlagCount wasn't being parsed correctly (#116) @FollowTheProcess ## :rotating_light: Testing * Use my new snapshot library (#119) @FollowTheProcess ## :construction_worker: Continuous Integration * Run vulncheck in CI (#114) @FollowTheProcess ## :hammer: Refactoring * Remove flag.Entry indirection in favour of an interface (#115) @FollowTheProcess ## :package: Dependencies * Bump github.com/FollowTheProcess/test from 0.16.0 to 0.17.1 (#118) @dependabot * Bump codecov/codecov-action from 4 to 5 (#117) @dependabot