Give -v to verbose, move --version to -V (closes #64)
check / check (push) Successful in 2m3s

urfave/cli's built-in version flag claimed -v, so "mfer -v --version"
failed to parse, and -v meant version at the root but verbose on
generate, check, freshen and fetch. Verbose is the more common meaning,
so the root now takes -v and -q too, the version flag takes -V, and a
-v or -q before the subcommand name applies to that subcommand.

User-visible changes: -v alone prints help with verbose logging, not
the version; use -V or --version. "mfer version" prints "mfer version
0.1.0 (...)", the same line as --version, instead of the bare
"0.1.0 (...)".

The error-message tests now send their log lines to io.Discard; they
were landing in other tests' output buffers.

Model: opus-4-8 (implementation); opus-5-5 (rework)
This commit is contained in:
2026-10-04 01:10:43 +00:00
parent c31796998f
commit c2e40f3d25
5 changed files with 163 additions and 10 deletions
+8 -2
View File
@@ -5,6 +5,7 @@ import (
"bytes"
"context"
"flag"
"io"
"net/http"
"net/http/httptest"
"os"
@@ -16,6 +17,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
urfcli "github.com/urfave/cli/v2"
"sneak.berlin/go/mfer/internal/log"
"sneak.berlin/go/mfer/mfer"
)
@@ -36,12 +38,16 @@ const (
msgFpB = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
)
// runLocked runs fn while holding runMu, so operations that write to the
// process-global logger do not race the other CLI runs.
// runLocked runs fn while holding runMu and with the process-global logger
// pointed at io.Discard, so fn's log lines neither race the other CLI runs
// nor land in the last run's buffers, which its test may still be reading.
func runLocked(fn func() error) error {
runMu.Lock()
defer runMu.Unlock()
log.SetOutput(io.Discard, io.Discard)
log.Init()
return fn()
}