code: func NewStackCommand(dockerCli command.Cli) *cobra.Command {
  	var opts commonOptions
  	cmd := &cobra.Command{
  		Use:   "stack [OPTIONS]",
  		Short: "Manage Docker stacks",
  		Args:  cli.NoArgs,
  		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
  			orchestrator, err := getOrchestrator(dockerCli, cmd)
  			if err != nil {
  				return err
  			}
  			opts.orchestrator = orchestrator
  			hideOrchestrationFlags(cmd, orchestrator)
  			return checkSupportedFlag(cmd, orchestrator)
  		},
  
  		RunE: command.ShowHelp(dockerCli.Err()),
  		Annotations: map[string]string{
  			"version": "1.25",
  		},
  	}
  	defaultHelpFunc := cmd.HelpFunc()
  	cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
  		if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
  			fmt.Fprintln(dockerCli.Err(), err)
  			return
  		}
  		if err := cmd.PersistentPreRunE(c, args); err != nil {
  			fmt.Fprintln(dockerCli.Err(), err)
  			return
  		}
  		hideOrchestrationFlags(c, opts.orchestrator)
  		defaultHelpFunc(c, args)
  	})
  	cmd.AddCommand(
  		newDeployCommand(dockerCli, &opts),
  		newListCommand(dockerCli, &opts),
  		newPsCommand(dockerCli, &opts),
  		newRemoveCommand(dockerCli, &opts),
  		newServicesCommand(dockerCli, &opts),
  	)
  	flags := cmd.PersistentFlags()
  	flags.String("kubeconfig", "", "Kubernetes config file")
  	flags.SetAnnotation("kubeconfig", "kubernetes", nil)
  	flags.String("orchestrator", "", "Orchestrator to use (swarm|kubernetes|all)")
  	return cmd
  }
docs: // NewStackCommand returns a cobra command for `stack` subcommands