MCPcopy
hub / github.com/spf13/cobra / TestLegacyArgsSubcmdAcceptsArgs

Function TestLegacyArgsSubcmdAcceptsArgs

args_test.go:530–541  ·  view source on GitHub ↗

This test make sure we keep backwards-compatibility with respect to the legacyArgs() function. It makes sure a sub-command accepts arguments and further sub-commands

(t *testing.T)

Source from the content-addressed store, hash-verified

528// to the legacyArgs() function.
529// It makes sure a sub-command accepts arguments and further sub-commands
530func TestLegacyArgsSubcmdAcceptsArgs(t *testing.T) {
531 rootCmd := &Command{Use: "root", Args: nil, Run: emptyRun}
532 childCmd := &Command{Use: "child", Args: nil, Run: emptyRun}
533 grandchildCmd := &Command{Use: "grandchild", Args: nil, Run: emptyRun}
534 rootCmd.AddCommand(childCmd)
535 childCmd.AddCommand(grandchildCmd)
536
537 _, err := executeCommand(rootCmd, "child", "somearg")
538 if err != nil {
539 t.Fatalf("Unexpected error: %v", err)
540 }
541}

Callers

nothing calls this directly

Calls 2

AddCommandMethod · 0.95
executeCommandFunction · 0.85

Tested by

no test coverage detected