From 8334864c34c3ef774f7f35dbb1fc54581cb51327 Mon Sep 17 00:00:00 2001 From: disble Date: Sun, 30 Aug 2026 16:41:00 -0500 Subject: [PATCH] feat(cmd): -v and --version, the spellings people type `ditto version` shipped in 0.8.0 and answers only its long forms. Nothing new is reported here; the point is that a tool which makes you look up how to ask its simplest question has not really answered it. Safe at this level rather than lucky: subcommands parse their flags with their own FlagSet, and Go's flag package does no prefix matching, so `ditto run -v` never resolved to -verbose and still does not -- it reports an undefined flag, exactly as before. Checked by running the binary, not only the suite. --- CHANGELOG.md | 14 ++++++++++++++ cmd/ditto/main.go | 3 ++- cmd/ditto/main_test.go | 5 ++++- readme.md | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 347e811..480e95f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.10.0] - 2026-08-30 + +### Added + +- **`-v` and `--version` alongside `ditto version`.** Nothing new is reported; + it is the spelling people actually type, and a tool that only answers the long + form makes them look it up to ask the simplest question it has. + + Safe at this level rather than lucky: subcommand flags are parsed by their own + `FlagSet`, and Go's `flag` package does no prefix matching, so `ditto run -v` + never resolved to `-verbose` and still does not — it reports an undefined flag, + as it always did. + ## [0.9.0] - 2026-08-30 The release that makes ditto's own gate finish, by making it ask a question it @@ -671,6 +684,7 @@ here, not yet built. - The `retract` block. It named published versions of the upstream module path, which do not exist under this one. +[0.10.0]: https://github.com/Disble/ditto/releases/tag/v0.10.0 [0.9.0]: https://github.com/Disble/ditto/releases/tag/v0.9.0 [0.8.0]: https://github.com/Disble/ditto/releases/tag/v0.8.0 [0.7.0]: https://github.com/Disble/ditto/releases/tag/v0.7.0 diff --git a/cmd/ditto/main.go b/cmd/ditto/main.go index fe82f84..c8d285d 100644 --- a/cmd/ditto/main.go +++ b/cmd/ditto/main.go @@ -55,7 +55,7 @@ func command(args []string, help io.Writer) error { usage(help) return nil - case "-version", "--version", "version": + case "-v", "-version", "--version", "version": fmt.Fprintln(help, versionLine(buildVersion())) return nil @@ -103,6 +103,7 @@ func usage(out io.Writer) { ditto staged [flags] mutate only what a staged change justifies ditto changed [flags] mutate only what a committed change justifies ditto version the module version this binary was built from + (also -v, --version) Run `+"`ditto run -h`"+` for its flags. `) diff --git a/cmd/ditto/main_test.go b/cmd/ditto/main_test.go index a46479e..9f114e3 100644 --- a/cmd/ditto/main_test.go +++ b/cmd/ditto/main_test.go @@ -28,7 +28,10 @@ func TestVersion(t *testing.T) { assert.Equal(t, "ditto (built from source; no released version recorded)", versionLine("")) }) - for _, argument := range []string{"--version", "-version", "version"} { + // -v as well as --version, because that is what people type. It is safe at + // this level: subcommand flags are parsed by their own FlagSet, and Go's flag + // package does no prefix matching, so `ditto run -v` was never a thing. + for _, argument := range []string{"--version", "-version", "-v", "version"} { t.Run(argument+" reports the version and does not fail", func(t *testing.T) { out := &bytes.Buffer{} diff --git a/readme.md b/readme.md index cf650f5..f37dccf 100644 --- a/readme.md +++ b/readme.md @@ -86,7 +86,7 @@ a gate rather than a test: ```shell go install github.com/Disble/ditto/cmd/ditto@latest -ditto version # which build is this? +ditto version # which build is this? (also -v, --version) ditto run --threshold 0.8 # mutate the repository ditto staged --dry # what would a staged change cost? ditto staged --threshold 0.8 # mutate only what it justifies