feat: add versioning

This commit is contained in:
2026-07-30 11:56:27 +02:00
parent e045bd39b2
commit 033b0bb5be
6 changed files with 74 additions and 1 deletions

View File

@@ -2,10 +2,34 @@ package main
import (
"bytes"
"regexp"
"strings"
"testing"
)
func TestVersionCommandPrintsSemanticVersion(t *testing.T) {
var output bytes.Buffer
handled, err := handleVersionCommand([]string{"--version"}, &output)
if err != nil {
t.Fatal(err)
}
if !handled || output.String() != "diple "+dipleVersion+"\n" {
t.Fatalf("version output = %q, handled=%t", output.String(), handled)
}
if !regexp.MustCompile(`^0\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(dipleVersion) {
t.Fatalf("version %q is not a pre-1.0 semantic version", dipleVersion)
}
}
func TestVersionCommandRejectsAdditionalArguments(t *testing.T) {
handled, err := handleVersionCommand(
[]string{"--version", "--help"}, &bytes.Buffer{},
)
if !handled || err == nil || !strings.Contains(err.Error(), "usage: diple --version") {
t.Fatalf("handled=%t error=%v", handled, err)
}
}
func TestCompletionCommandGeneratesSupportedShells(t *testing.T) {
for _, shell := range completionShells {
t.Run(shell, func(t *testing.T) {
@@ -65,6 +89,7 @@ func TestCLIHelpIsGroupedAndActionable(t *testing.T) {
"Appearance and navigation:",
"Local state:",
"diple completion <bash|zsh|fish>",
"--version",
"--repo OWNER/REPOSITORY",
"--cache=false",
"gh auth login",