diff --git a/Taskfile.yml b/Taskfile.yml index 0762ec9..3644628 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -77,7 +77,7 @@ tasks: desc: Render the demo gifs sources: - ./docs/src/*.tape - - examples/**/*.go + - "**/*.go" preconditions: - sh: command -v vhs msg: vhs not installed, see https://github.com/charmbracelet/vhs diff --git a/docs/img/quickstart.gif b/docs/img/quickstart.gif index 4540477..061caee 100644 Binary files a/docs/img/quickstart.gif and b/docs/img/quickstart.gif differ diff --git a/internal/flag/set.go b/internal/flag/set.go index bff5e94..8c951a2 100644 --- a/internal/flag/set.go +++ b/internal/flag/set.go @@ -213,7 +213,27 @@ func (s *Set) Usage() (string, error) { shorthand = "N/A" } - tab.Row(" %s\t--%s\t%s\t%s\n", colour.Bold(shorthand), colour.Bold(entry.Name), entry.Value.Type(), entry.Usage) + if entry.DefaultValue != "" { + // Plain string + tab.Row( + " %s\t--%s\t%s\t%s [default %s]\n", + colour.Bold(shorthand), + colour.Bold(entry.Name), + entry.Value.Type(), + entry.Usage, + entry.DefaultValue, + ) + } else { + // Empty string so use the quotes + tab.Row( + " %s\t--%s\t%s\t%s [default %q]\n", + colour.Bold(shorthand), + colour.Bold(entry.Name), + entry.Value.Type(), + entry.Usage, + entry.DefaultValue, + ) + } } if err := tab.Flush(); err != nil { diff --git a/internal/flag/testdata/TestUsage/full.txt b/internal/flag/testdata/TestUsage/full.txt index 87779c0..d4402e3 100755 --- a/internal/flag/testdata/TestUsage/full.txt +++ b/internal/flag/testdata/TestUsage/full.txt @@ -1,5 +1,5 @@ - -c --count int Count things - -h --help bool Show help for test - -t --thing string Name the thing - N/A --update bool Update something - -V --version bool Show version info for test + -c --count int Count things [default 0] + -h --help bool Show help for test [default false] + -t --thing string Name the thing [default ""] + N/A --update bool Update something [default false] + -V --version bool Show version info for test [default false] diff --git a/internal/flag/testdata/TestUsage/no-shorthand.txt b/internal/flag/testdata/TestUsage/no-shorthand.txt index bdd95f5..c40e27b 100644 --- a/internal/flag/testdata/TestUsage/no-shorthand.txt +++ b/internal/flag/testdata/TestUsage/no-shorthand.txt @@ -1,3 +1,3 @@ - -h --help bool Show help for test - N/A --update bool Update something - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + N/A --update bool Update something [default false] + -V --version bool Show version info for test [default false] diff --git a/internal/flag/testdata/TestUsage/simple.txt b/internal/flag/testdata/TestUsage/simple.txt index bc9495e..e9716f1 100644 --- a/internal/flag/testdata/TestUsage/simple.txt +++ b/internal/flag/testdata/TestUsage/simple.txt @@ -1,2 +1,2 @@ - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] diff --git a/testdata/TestHelp/default-help.txt b/testdata/TestHelp/default-help.txt index 2dd88a7..0aea153 100644 --- a/testdata/TestHelp/default-help.txt +++ b/testdata/TestHelp/default-help.txt @@ -3,5 +3,5 @@ A placeholder for something cool Usage: test [OPTIONS] ARGS... Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] diff --git a/testdata/TestHelp/full.txt b/testdata/TestHelp/full.txt index 78efc0a..a182c35 100644 --- a/testdata/TestHelp/full.txt +++ b/testdata/TestHelp/full.txt @@ -5,5 +5,5 @@ A longer, probably multiline description Usage: test [OPTIONS] ARGS... Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] diff --git a/testdata/TestHelp/no-about.txt b/testdata/TestHelp/no-about.txt index 2dd88a7..0aea153 100644 --- a/testdata/TestHelp/no-about.txt +++ b/testdata/TestHelp/no-about.txt @@ -3,5 +3,5 @@ A placeholder for something cool Usage: test [OPTIONS] ARGS... Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] diff --git a/testdata/TestHelp/subcommands-different-lengths.txt b/testdata/TestHelp/subcommands-different-lengths.txt index c28c1e7..f917915 100755 --- a/testdata/TestHelp/subcommands-different-lengths.txt +++ b/testdata/TestHelp/subcommands-different-lengths.txt @@ -10,7 +10,7 @@ Commands: very-long-subcommand Wow so long Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] Use "test [command] -h/--help" for more information about a command. diff --git a/testdata/TestHelp/subcommands-flags.txt b/testdata/TestHelp/subcommands-flags.txt index f83f55d..0697a55 100644 --- a/testdata/TestHelp/subcommands-flags.txt +++ b/testdata/TestHelp/subcommands-flags.txt @@ -9,9 +9,9 @@ Commands: sub2 Do another thing Options: - N/A --count int Count something - -d --delete bool Delete something - -h --help bool Show help for test - -V --version bool Show version info for test + N/A --count int Count something [default -1] + -d --delete bool Delete something [default false] + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] Use "test [command] -h/--help" for more information about a command. diff --git a/testdata/TestHelp/subcommands.txt b/testdata/TestHelp/subcommands.txt index 82530f2..e422080 100644 --- a/testdata/TestHelp/subcommands.txt +++ b/testdata/TestHelp/subcommands.txt @@ -9,7 +9,7 @@ Commands: sub2 Do another thing Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] Use "test [command] -h/--help" for more information about a command. diff --git a/testdata/TestHelp/with-examples.txt b/testdata/TestHelp/with-examples.txt index 900233a..b411260 100644 --- a/testdata/TestHelp/with-examples.txt +++ b/testdata/TestHelp/with-examples.txt @@ -10,5 +10,5 @@ $ test do thing --now $ test do thing --different Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false] diff --git a/testdata/TestHelp/with-named-arguments.txt b/testdata/TestHelp/with-named-arguments.txt index 65a6578..ee60c26 100644 --- a/testdata/TestHelp/with-named-arguments.txt +++ b/testdata/TestHelp/with-named-arguments.txt @@ -7,5 +7,5 @@ Arguments: dest Destination to copy to [default ./dest] Options: - -h --help bool Show help for test - -V --version bool Show version info for test + -h --help bool Show help for test [default false] + -V --version bool Show version info for test [default false]