Skip to content

Commit

Permalink
cli: fix generated CLI docs for pulumi/pulumi
Browse files Browse the repository at this point in the history
Create a copy of the open/run command structs before adding them as top-level aliases. This is done because `AddCommand` mutates fields on the Command struct, changing its parent, which causes docs to not be generated correctly from the pulumi/pulumi CLI.
  • Loading branch information
justinvp authored and lblackstone committed Oct 18, 2023
1 parent d6d0769 commit 1359ae0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/esc/cli/esc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,15 @@ func New(opts *Options) *cobra.Command {

env := newEnvCmd(esc)
cmd.AddCommand(env)
cmd.AddCommand(getCommand(env, "open"))
cmd.AddCommand(getCommand(env, "run"))

// Add top-level open/run aliases. We copy the commands to new struct values because
// `AddCommand` mutates the command, modifying its parent, which can cause issues
// with generated docs.
openCmdCopy := *getCommand(env, "open")
runCmdCopy := *getCommand(env, "run")
cmd.AddCommand(&openCmdCopy)
cmd.AddCommand(&runCmdCopy)

cmd.AddCommand(newLoginCmd(esc))
cmd.AddCommand(newLogoutCmd(esc))
cmd.AddCommand(newVersionCmd(esc))
Expand Down

0 comments on commit 1359ae0

Please sign in to comment.