spf13/cobra

Is there a level to how many levels you can descend?

SimplySeth opened this issue · 3 comments

In my code, I can only go down to the second level
i.e <script> gcp access

Desired outcome would be to do

<script> gcp access annotate or <script> ssh access list Basically all the `commoncmd/*` commands won't run of which annotate is one of them https://github.com/SimplySeth/cobrafail
nirs commented

@SimplySeth your description is not clear.

  • What is the expected behavior?
  • What is the actual behavior?
  • Can you show a short code example reproducing the issue? I guess we can see the issue in https://github.com/SimplySeth/cobrafail/ but it looks too big and complicated for an example of the issue

Expected behavior
go run . gcp access annotate should result in "annotate was run"

Actual behavior
go run . gcp access annotate results in no output

Short code example
https://gist.github.com/SimplySeth/fb67b298ab3d45ee2135e4e4f41f31ce

go run . gcp *works
go run . gcp access *works
go run . ssh *works
go run . ssh access *works

I needed to load the commands using the defined pointers ...

var (
	GcpAccessCmd = *AccessCmd
	SshAccessCmd = *AccessCmd
)

func init() {
	GcpAccessCmd.AddCommand(&commoncmd.AccessGetCmd)
	SshAccessCmd.AddCommand(&commoncmd.AccessGetCmd)
}