Add generated help and version commands
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
spfcobra "github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func TestParseRoutesBeforeOptionsAndKeepsFlagsLocal(t *testing.T) {
|
||||
@@ -29,6 +31,18 @@ func TestParseRoutesBeforeOptionsAndKeepsFlagsLocal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseRequiresExactCommandPathWhenPrefixMatchingIsEnabled(t *testing.T) {
|
||||
previous := spfcobra.EnablePrefixMatching
|
||||
spfcobra.EnablePrefixMatching = true
|
||||
t.Cleanup(func() { spfcobra.EnablePrefixMatching = previous })
|
||||
|
||||
tree := &Command{Name: "app", Children: []*Command{{Name: "config", Runnable: true}}}
|
||||
result := Parse(tree, []string{"con"}, ParseOptions{})
|
||||
if result.Failure == nil {
|
||||
t.Fatal("accepted a prefixed command path")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseInterspersedOperandsBooleanFlagsAndTerminator(t *testing.T) {
|
||||
tree := &Command{Name: "app", Children: []*Command{
|
||||
{Name: "restore", Runnable: true, Flags: []Flag{
|
||||
|
||||
Reference in New Issue
Block a user