Compare commits

..
1 Commits
Author SHA1 Message Date
sneak 8f6b15b8ad Make -v count once and accept -vv for debug output (closes #125)
check / check (push) Failing after 2s
urfave/cli before v2.25.5 counted a flag given by its alias twice, so
one -v or --verbose already gave debug output. Bump it to v2.27.7, the
latest v2 release, which counts it once: one -v gives verbose output,
two give debug.

Turn on urfave/cli's UseShortOptionHandling so single-letter flags
combine at the root and in every subcommand; -vv now works as the -v
help text says.

-v and --verbose together stay refused: urfave/cli v2 refuses any flag
given under two of its names.

The bump drops "[arguments...]" from usage lines, so generate and fetch
now name their arguments. Test runs now start at the default log level.

Model: opus-5-5
2026-10-04 07:59:34 +00:00
3 changed files with 15 additions and 17 deletions
-2
View File
@@ -75,7 +75,5 @@ RUN version="${VERSION:-$(git describe --tags --always)}"; \
RUN ldd /mfer 2>&1 | grep -q 'not a dynamic executable'
FROM scratch
# scratch has no CA certificates; fetch needs them to verify HTTPS servers.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /mfer /mfer
ENTRYPOINT ["/mfer"]
+7 -10
View File
@@ -291,9 +291,9 @@ func TestVerboseCount(t *testing.T) {
}
}
// TestCombinedShortVerboseRefused asserts that -vv is refused (issue #125):
// single-letter flags do not combine, so the -v help text says -v -v.
func TestCombinedShortVerboseRefused(t *testing.T) {
// TestCombinedShortVerbose asserts that -vv gives debug output wherever -v
// is taken, as the -v help text says (issue #125).
func TestCombinedShortVerbose(t *testing.T) {
t.Parallel()
for _, command := range commandsTakingVerbose() {
@@ -303,18 +303,15 @@ func TestCombinedShortVerboseRefused(t *testing.T) {
t.Parallel()
opts := testOpts(args, afero.NewMemMapFs())
exitCode, level := runCLIWithLevel(opts)
assert.Equal(t, 1, exitCode)
assert.Contains(t, testStderr(t, opts), "flag provided but not defined: -vv")
assert.Equal(t, log.InfoLevel, level)
_, level := runCLIWithLevel(opts)
assert.Equal(t, log.DebugLevel, level, "stderr: %s", testStderr(t, opts))
})
}
}
// TestShortAndLongVerboseRefused asserts that -v and --verbose given together
// are refused (issue #125): urfave/cli v2 refuses a flag given under two of its
// names, and one flag with an alias keeps help and parsing simple.
// are refused (issue #125): urfave/cli v2 refuses any flag given under two of
// its names, and accepting it would take parsing the arguments by hand.
func TestShortAndLongVerboseRefused(t *testing.T) {
t.Parallel()
+8 -5
View File
@@ -119,7 +119,7 @@ func commonFlags() []cli.Flag {
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "Increase verbosity (-v for verbose, -v -v for debug)",
Usage: "Increase verbosity (-v for verbose, -vv for debug)",
Count: new(int),
},
&cli.BoolFlag{
@@ -328,7 +328,7 @@ func (mfa *CLIApp) fetchCommand() *cli.Command {
return &cli.Command{
Name: cmdFetch,
Usage: "fetch manifest and referenced files",
ArgsUsage: "URL",
ArgsUsage: "[URL]",
Action: func(c *cli.Context) error {
mfa.setVerbosity(c)
mfa.printBanner()
@@ -371,9 +371,12 @@ func (mfa *CLIApp) run(args []string) {
Usage: "Manifest generator",
Version: mfa.VersionString(),
EnableBashCompletion: true,
Writer: mfa.Stdout,
ErrWriter: mfa.Stderr,
Flags: commonFlags(),
// Lets single-letter flags combine, at the root and in every
// subcommand: -vv is -v -v.
UseShortOptionHandling: true,
Writer: mfa.Stdout,
ErrWriter: mfa.Stderr,
Flags: commonFlags(),
Action: func(c *cli.Context) error {
if c.Args().Len() > 0 {
return fmt.Errorf("%w %q", errUnknownCommand, c.Args().First())