fix: add missing help descriptions on some cmds
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
func newInitCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialise mire in the current project",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if err := mire.Init(); err != nil {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
func newRecordCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "record <path>",
|
||||
Short: "Record a new CLI scenario",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
path := filepath.Clean(args[0])
|
||||
|
||||
@@ -29,6 +29,9 @@ func newRootCommand() *cobra.Command {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "mire",
|
||||
Short: "A lean CLI E2E testing framework.",
|
||||
CompletionOptions: cobra.CompletionOptions{
|
||||
HiddenDefaultCmd: true,
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return cmd.Help()
|
||||
},
|
||||
|
||||
+28
-2
@@ -21,8 +21,34 @@ func TestRunShowsHelpWhenNoArgs(t *testing.T) {
|
||||
if !strings.Contains(stdout, "A lean CLI E2E testing framework.") {
|
||||
t.Fatalf("stdout = %q, want root help", stdout)
|
||||
}
|
||||
if !strings.Contains(stdout, "init") || !strings.Contains(stdout, "record") || !strings.Contains(stdout, "test") {
|
||||
t.Fatalf("stdout = %q, want listed subcommands", stdout)
|
||||
for _, want := range []string{
|
||||
"init Initialise mire in the current project",
|
||||
"record Record a new CLI scenario",
|
||||
"test Replay recorded CLI scenarios",
|
||||
} {
|
||||
if !strings.Contains(stdout, want) {
|
||||
t.Fatalf("stdout = %q, want listed subcommand %q", stdout, want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(stdout, "completion") {
|
||||
t.Fatalf("stdout = %q, want hidden completion command", stdout)
|
||||
}
|
||||
if stderr != "" {
|
||||
t.Fatalf("stderr = %q, want empty", stderr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunCompletionStillWorksWhenHidden(t *testing.T) {
|
||||
testutil.AddFakeRecordDependencies(t, "bwrap", "bash")
|
||||
|
||||
stdout, stderr := testutil.CaptureOutput(t, func() {
|
||||
if got := Run([]string{"completion", "bash"}); got != 0 {
|
||||
t.Fatalf("Run() code = %d, want %d", got, 0)
|
||||
}
|
||||
})
|
||||
|
||||
if !strings.Contains(stdout, "# bash completion V2 for mire") {
|
||||
t.Fatalf("stdout = %q, want bash completion script", stdout)
|
||||
}
|
||||
if stderr != "" {
|
||||
t.Fatalf("stderr = %q, want empty", stderr)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
func newTestCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "test [path]",
|
||||
Short: "Replay recorded CLI scenarios",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
path := ""
|
||||
|
||||
Reference in New Issue
Block a user