Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e33c37c82 | ||
|
|
588c1bae74 |
@@ -75,5 +75,7 @@ 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"]
|
||||
|
||||
@@ -291,9 +291,9 @@ func TestVerboseCount(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) {
|
||||
// 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) {
|
||||
t.Parallel()
|
||||
|
||||
for _, command := range commandsTakingVerbose() {
|
||||
@@ -303,15 +303,18 @@ func TestCombinedShortVerbose(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
opts := testOpts(args, afero.NewMemMapFs())
|
||||
_, level := runCLIWithLevel(opts)
|
||||
assert.Equal(t, log.DebugLevel, level, "stderr: %s", testStderr(t, opts))
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestShortAndLongVerboseRefused asserts that -v and --verbose given together
|
||||
// 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.
|
||||
// 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.
|
||||
func TestShortAndLongVerboseRefused(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ func commonFlags() []cli.Flag {
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
Aliases: []string{"v"},
|
||||
Usage: "Increase verbosity (-v for verbose, -vv for debug)",
|
||||
Usage: "Increase verbosity (-v for verbose, -v -v 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,12 +371,9 @@ func (mfa *CLIApp) run(args []string) {
|
||||
Usage: "Manifest generator",
|
||||
Version: mfa.VersionString(),
|
||||
EnableBashCompletion: true,
|
||||
// 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(),
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user