A bare `talk version` was spoken as an announcement because only the --version flag existed. The subcommand prints the same line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d9d2a86e9
commit
07c89f4939
3 files changed
+22
No files matched your search
@@ -112,6 +112,15 @@ var commands = []command{
|
||||
detail: "Asks a few questions for what talk needs to get going: keys (optional; without a key the free Edge voice speaks), a voice per language with preview, quiet hours, and writes config.toml (an existing file is merged, backup .bak). Without a terminal: only shows the effective configuration.",
|
||||
handler: runSetup,
|
||||
},
|
||||
{
|
||||
name: "version",
|
||||
short: "show the version",
|
||||
detail: "Prints the version and, when built from git, the commit. Same as `talk --version`; exists so that a bare `talk version` is not spoken as an announcement.",
|
||||
handler: func(_ []string, _ *sayOptions, _ io.Reader, stdout, _ io.Writer) int {
|
||||
fmt.Fprintln(stdout, versionString())
|
||||
return exitOK
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// addSayFlags registers the say flags and binds them to the returned options
|
||||
|
||||
@@ -52,6 +52,18 @@ func TestVersionDefault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestVersionSubcommand: `talk version` prints the version instead of
|
||||
// speaking the word.
|
||||
func TestVersionSubcommand(t *testing.T) {
|
||||
var out, errBuf bytes.Buffer
|
||||
if code := runCLI([]string{"version"}, &out, &errBuf); code != exitOK {
|
||||
t.Fatalf("version: exit code = %d, stderr %q", code, errBuf.String())
|
||||
}
|
||||
if got, want := out.String(), versionString()+"\n"; got != want {
|
||||
t.Errorf("version output = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionStringWithCommit(t *testing.T) {
|
||||
oldCommit := commit
|
||||
commit = "c0ffee1"
|
||||
|
||||
Reference in new issue
Block a user