| 1 | // Copyright 2019 The Kubernetes Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package configcobra_test |
| 5 | |
| 6 | import ( |
| 7 | "os" |
| 8 | |
| 9 | "github.com/spf13/cobra" |
| 10 | "sigs.k8s.io/kustomize/cmd/config/configcobra" |
| 11 | "sigs.k8s.io/kustomize/kyaml/commandutil" |
| 12 | ) |
| 13 | |
| 14 | // ExampleAddCommands demonstrates how to embed the config command as a command inside |
| 15 | // another group. |
| 16 | func ExampleAddCommands() { |
| 17 | // enable the config commands |
| 18 | os.Setenv(commandutil.EnableAlphaCommmandsEnvName, "true") |
| 19 | _ = configcobra.AddCommands(&cobra.Command{ |
| 20 | Use: "my-cmd", |
| 21 | Short: "My command.", |
| 22 | Long: `My command.`, |
| 23 | }, "my-cmd") |
| 24 | } |