@@ -56,6 +56,33 @@ func TestInvalidPlugin(t *testing.T) {
5656 assert .DeepEqual (t , invalidPlugins (root ), []* cobra.Command {sub1 }, cmpopts .IgnoreUnexported (cobra.Command {}))
5757}
5858
59+ func TestHiddenPlugin (t * testing.T ) {
60+ root := & cobra.Command {Use : "root" }
61+ sub1 := & cobra.Command {
62+ Use : "sub1" ,
63+ Hidden : true ,
64+ Annotations : map [string ]string {
65+ metadata .CommandAnnotationPlugin : "true" ,
66+ },
67+ Run : func (cmd * cobra.Command , args []string ) {},
68+ }
69+
70+ sub1sub1 := & cobra.Command {Use : "sub1sub1" }
71+ sub1sub2 := & cobra.Command {Use : "sub1sub2" }
72+ sub2 := & cobra.Command {
73+ Use : "sub2" ,
74+ Annotations : map [string ]string {
75+ metadata .CommandAnnotationPlugin : "true" ,
76+ },
77+ Run : func (cmd * cobra.Command , args []string ) {},
78+ }
79+
80+ root .AddCommand (sub1 , sub2 )
81+ sub1 .AddCommand (sub1sub1 , sub1sub2 )
82+
83+ assert .DeepEqual (t , allManagementSubCommands (root ), []* cobra.Command {sub2 }, cmpopts .IgnoreFields (cobra.Command {}, "Run" ), cmpopts .IgnoreUnexported (cobra.Command {}))
84+ }
85+
5986func TestCommandAliases (t * testing.T ) {
6087 root := & cobra.Command {Use : "root" }
6188 sub := & cobra.Command {Use : "subcommand" , Aliases : []string {"alias1" , "alias2" }}
0 commit comments