test update, more consistent default value display
This commit is contained in:
parent
b9e261c34a
commit
b6dadfa7fb
10 changed files with 24 additions and 21 deletions
|
|
@ -107,7 +107,7 @@ func TestManPrintFlagsHidesShortDeprecated(t *testing.T) {
|
|||
manPrintFlags(buf, c.Flags())
|
||||
|
||||
got := buf.String()
|
||||
expected := "`--foo` `<string> (Default: default)`\n: Foo flag\n\n"
|
||||
expected := "`--foo` `<string> (default \"default\")`\n: Foo flag\n\n"
|
||||
if got != expected {
|
||||
t.Errorf("Expected %q, got %q", expected, got)
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ func TestManPrintFlagsShowsDefaultValues(t *testing.T) {
|
|||
manPrintFlags(buf, c.Flags())
|
||||
|
||||
got := buf.String()
|
||||
expected := "`--limit` `<int> (Default: 30)`\n: Some limit\n\n"
|
||||
expected := "`--limit` `<int> (default 30)`\n: Some limit\n\n"
|
||||
if got != expected {
|
||||
t.Errorf("Expected %q, got %q", expected, got)
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ func TestManPrintFlagsShowsDefaultValues(t *testing.T) {
|
|||
manPrintFlags(buf, c.Flags())
|
||||
|
||||
got = buf.String()
|
||||
expected = "`--no-archived` `(Default: true)`\n: Hide archived\n\n"
|
||||
expected = "`--no-archived` `(default true)`\n: Hide archived\n\n"
|
||||
if got != expected {
|
||||
t.Errorf("Expected %q, got %q", expected, got)
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ func TestManPrintFlagsShowsDefaultValues(t *testing.T) {
|
|||
manPrintFlags(buf, c.Flags())
|
||||
|
||||
got = buf.String()
|
||||
expected = "`--template` `<string> (Default: T1)`\n: Some template\n\n"
|
||||
expected = "`--template` `<string> (default \"T1\")`\n: Some template\n\n"
|
||||
if got != expected {
|
||||
t.Errorf("Expected %q, got %q", expected, got)
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ func TestManPrintFlagsShowsDefaultValues(t *testing.T) {
|
|||
manPrintFlags(buf, c.Flags())
|
||||
|
||||
got = buf.String()
|
||||
expected = "`--topic` `<strings> (Default: [apples,oranges])`\n: Some topics\n\n"
|
||||
expected = "`--topic` `<strings> (default [apples,oranges])`\n: Some topics\n\n"
|
||||
if got != expected {
|
||||
t.Errorf("Expected %q, got %q", expected, got)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func getDefaultValueDisplayString(f *pflag.Flag) string {
|
|||
if dvf, found := defaultValFormats[f.Value.Type()]; found {
|
||||
return fmt.Sprintf(dvf, f.Value)
|
||||
}
|
||||
return fmt.Sprintf(" (default: %s)", f.Value)
|
||||
return fmt.Sprintf(" (default %s)", f.Value)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output := buf.String()
|
||||
|
||||
checkStringContains(t, output, "(Default: 30)")
|
||||
checkStringContains(t, output, "(default 30)")
|
||||
|
||||
// Bool flag should hide it if default is false
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -142,7 +142,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringOmits(t, output, "(Default: ")
|
||||
checkStringOmits(t, output, "(default ")
|
||||
|
||||
// Bool flag should show it if default is true
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -156,7 +156,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringContains(t, output, "(Default: true)")
|
||||
checkStringContains(t, output, "(default true)")
|
||||
|
||||
// String flag should show it if default is not an empty string
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -170,7 +170,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringContains(t, output, "(Default: T1)")
|
||||
checkStringContains(t, output, "(default "T1")")
|
||||
|
||||
// String flag should hide it if default is an empty string
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -185,7 +185,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringOmits(t, output, "(Default: ")
|
||||
checkStringOmits(t, output, "(default ")
|
||||
|
||||
// String slice flag should hide it if default is an empty slice
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -199,7 +199,7 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringOmits(t, output, "(Default: ")
|
||||
checkStringOmits(t, output, "(default ")
|
||||
|
||||
// String slice flag should show it if default is not an empty slice
|
||||
c = &cobra.Command{}
|
||||
|
|
@ -213,5 +213,5 @@ func TestPrintFlagsHTMLShowsDefaultValues(t *testing.T) {
|
|||
}
|
||||
output = buf.String()
|
||||
|
||||
checkStringContains(t, output, "(Default: [apples,oranges])")
|
||||
checkStringContains(t, output, "(default [apples,oranges])")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,11 @@ func NewCmdConfig(f *cmdutil.Factory) *cobra.Command {
|
|||
longDoc.WriteString("Current respected settings:\n")
|
||||
for _, co := range config.ConfigOptions() {
|
||||
longDoc.WriteString(fmt.Sprintf("- %s: %s", co.Key, co.Description))
|
||||
if len(co.AllowedValues) > 0 {
|
||||
longDoc.WriteString(fmt.Sprintf(" {%s}", strings.Join(co.AllowedValues, "|")))
|
||||
}
|
||||
if co.DefaultValue != "" {
|
||||
longDoc.WriteString(fmt.Sprintf(" (default: %q)", co.DefaultValue))
|
||||
longDoc.WriteString(fmt.Sprintf(" (default %s)", co.DefaultValue))
|
||||
}
|
||||
longDoc.WriteRune('\n')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
|||
|
||||
cmd.Flags().StringVarP(&opts.Description, "desc", "d", "", "A description for this gist")
|
||||
cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the web browser with created gist")
|
||||
cmd.Flags().BoolVarP(&opts.Public, "public", "p", false, "List the gist publicly (default: secret)")
|
||||
cmd.Flags().BoolVarP(&opts.Public, "public", "p", false, "List the gist publicly (default \"secret\")")
|
||||
cmd.Flags().StringVarP(&opts.FilenameOverride, "filename", "f", "", "Provide a filename to be used when reading from standard input")
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func NewCmdCheckout(f *cmdutil.Factory, runF func(*CheckoutOptions) error) *cobr
|
|||
cmd.Flags().BoolVarP(&opts.RecurseSubmodules, "recurse-submodules", "", false, "Update all submodules after checkout")
|
||||
cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Reset the existing local branch to the latest state of the pull request")
|
||||
cmd.Flags().BoolVarP(&opts.Detach, "detach", "", false, "Checkout PR with a detached HEAD")
|
||||
cmd.Flags().StringVarP(&opts.BranchName, "branch", "b", "", "Local branch name to use (default: the name of the head branch)")
|
||||
cmd.Flags().StringVarP(&opts.BranchName, "branch", "b", "", "Local branch name to use (default <the name of the head branch>)")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
|||
fl.StringVarP(&opts.Body, "body", "b", "", "Body for the pull request")
|
||||
fl.StringVarP(&bodyFile, "body-file", "F", "", "Read body text from `file` (use \"-\" to read from standard input)")
|
||||
fl.StringVarP(&opts.BaseBranch, "base", "B", "", "The `branch` into which you want your code merged")
|
||||
fl.StringVarP(&opts.HeadBranch, "head", "H", "", "The `branch` that contains commits for your pull request (default: current branch)")
|
||||
fl.StringVarP(&opts.HeadBranch, "head", "H", "", "The `branch` that contains commits for your pull request (default <current branch>)")
|
||||
fl.BoolVarP(&opts.WebMode, "web", "w", false, "Open the web browser to create a pull request")
|
||||
fl.BoolVarP(&opts.Autofill, "fill", "f", false, "Use commit info for title and body")
|
||||
fl.BoolVar(&opts.FillFirst, "fill-first", false, "Use first commit info for title and body")
|
||||
|
|
|
|||
|
|
@ -178,14 +178,14 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
|
|||
|
||||
cmd.Flags().BoolVarP(&opts.Draft, "draft", "d", false, "Save the release as a draft instead of publishing it")
|
||||
cmd.Flags().BoolVarP(&opts.Prerelease, "prerelease", "p", false, "Mark the release as a prerelease")
|
||||
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or full commit SHA (default: main branch)")
|
||||
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or full commit SHA (default <main branch>)")
|
||||
cmd.Flags().StringVarP(&opts.Name, "title", "t", "", "Release title")
|
||||
cmd.Flags().StringVarP(&opts.Body, "notes", "n", "", "Release notes")
|
||||
cmd.Flags().StringVarP(¬esFile, "notes-file", "F", "", "Read release notes from `file` (use \"-\" to read from standard input)")
|
||||
cmd.Flags().StringVarP(&opts.DiscussionCategory, "discussion-category", "", "", "Start a discussion in the specified category")
|
||||
cmd.Flags().BoolVarP(&opts.GenerateNotes, "generate-notes", "", false, "Automatically generate title and notes for the release")
|
||||
cmd.Flags().StringVar(&opts.NotesStartTag, "notes-start-tag", "", "Tag to use as the starting point for generating release notes")
|
||||
cmdutil.NilBoolFlag(cmd, &opts.IsLatest, "latest", "", "Mark this release as \"Latest\" (default: automatic based on date and version)")
|
||||
cmdutil.NilBoolFlag(cmd, &opts.IsLatest, "latest", "", "Mark this release as \"Latest\" (default <automatic based on date and version>)")
|
||||
cmd.Flags().BoolVarP(&opts.VerifyTag, "verify-tag", "", false, "Abort in case the git tag doesn't already exist in the remote repository")
|
||||
cmd.Flags().BoolVarP(&opts.NotesFromTag, "notes-from-tag", "", false, "Automatically generate notes from annotated tag")
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
|
|||
cmdutil.NilStringFlag(cmd, &opts.Body, "notes", "n", "Release notes")
|
||||
cmdutil.NilStringFlag(cmd, &opts.Name, "title", "t", "Release title")
|
||||
cmdutil.NilStringFlag(cmd, &opts.DiscussionCategory, "discussion-category", "", "Start a discussion in the specified category when publishing a draft")
|
||||
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or full commit SHA (default: main branch)")
|
||||
cmd.Flags().StringVar(&opts.Target, "target", "", "Target `branch` or full commit SHA (default <main branch>)")
|
||||
cmd.Flags().StringVar(&opts.TagName, "tag", "", "The name of the tag")
|
||||
cmd.Flags().StringVarP(¬esFile, "notes-file", "F", "", "Read release notes from `file` (use \"-\" to read from standard input)")
|
||||
cmd.Flags().BoolVar(&opts.VerifyTag, "verify-tag", false, "Abort in case the git tag doesn't already exist in the remote repository")
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func NewCmdSync(f *cmdutil.Factory, runF func(*SyncOptions) error) *cobra.Comman
|
|||
}
|
||||
|
||||
cmd.Flags().StringVarP(&opts.SrcArg, "source", "s", "", "Source repository")
|
||||
cmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "Branch to sync (default: default branch)")
|
||||
cmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "Branch to sync (default <default branch>)")
|
||||
cmd.Flags().BoolVarP(&opts.Force, "force", "", false, "Hard reset the branch of the destination repository to match the source repository")
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue