Add bash completion cmd

pull/16/head
stefanprodan 5 years ago
parent 155cc66db9
commit afcb41c59b

@ -23,3 +23,6 @@ install:
.PHONY: docs .PHONY: docs
docs: docs:
mkdir -p ./docs/cmd && go run ./cmd/tk/ docgen mkdir -p ./docs/cmd && go run ./cmd/tk/ docgen
install-dev:
CGO_ENABLED=0 go build -o /usr/local/bin ./cmd/tk

@ -0,0 +1,28 @@
package main
import (
"os"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generates bash completion scripts",
Example: `To load completion run
. <(tk completion)
To configure your bash shell to load completions for each session add to your bashrc
# ~/.bashrc or ~/.profile
. <(tk completion)
`,
Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenBashCompletion(os.Stdout)
},
}
func init() {
rootCmd.AddCommand(completionCmd)
}

@ -47,15 +47,11 @@ func deleteKsCmdRun(cmd *cobra.Command, args []string) error {
} }
if !deleteSilent { if !deleteSilent {
warning := "This action will remove the Kubernetes objects previously applied by this kustomization. " if !kustomization.Spec.Suspend {
if kustomization.Spec.Suspend { logWaiting("This action will remove the Kubernetes objects previously applied by the %s kustomization!", name)
warning = ""
} }
prompt := promptui.Prompt{ prompt := promptui.Prompt{
Label: fmt.Sprintf( Label: "Are you sure you want to delete this kustomization",
"%sAre you sure you want to delete the %s kustomization from the %s namespace",
warning, name, namespace,
),
IsConfirm: true, IsConfirm: true,
} }
if _, err := prompt.Run(); err != nil { if _, err := prompt.Run(); err != nil {

@ -47,9 +47,7 @@ func deleteSourceGitCmdRun(cmd *cobra.Command, args []string) error {
if !deleteSilent { if !deleteSilent {
prompt := promptui.Prompt{ prompt := promptui.Prompt{
Label: fmt.Sprintf( Label: "Are you sure you want to delete this source",
"Are you sure you want to delete the %s source from the %s namespace", name, namespace,
),
IsConfirm: true, IsConfirm: true,
} }
if _, err := prompt.Run(); err != nil { if _, err := prompt.Run(); err != nil {

@ -79,6 +79,7 @@ Command line utility for assembling Kubernetes CD pipelines the GitOps way.
### SEE ALSO ### SEE ALSO
* [tk check](tk_check.md) - Check requirements and installation * [tk check](tk_check.md) - Check requirements and installation
* [tk completion](tk_completion.md) - Generates bash completion scripts
* [tk create](tk_create.md) - Create commands * [tk create](tk_create.md) - Create commands
* [tk delete](tk_delete.md) - Delete commands * [tk delete](tk_delete.md) - Delete commands
* [tk export](tk_export.md) - Export commands * [tk export](tk_export.md) - Export commands
@ -89,4 +90,4 @@ Command line utility for assembling Kubernetes CD pipelines the GitOps way.
* [tk sync](tk_sync.md) - Synchronize commands * [tk sync](tk_sync.md) - Synchronize commands
* [tk uninstall](tk_uninstall.md) - Uninstall the toolkit components * [tk uninstall](tk_uninstall.md) - Uninstall the toolkit components
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -44,4 +44,4 @@ tk check [flags]
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -0,0 +1,47 @@
## tk completion
Generates bash completion scripts
### Synopsis
Generates bash completion scripts
```
tk completion [flags]
```
### Examples
```
To load completion run
. <(tk completion)
To configure your bash shell to load completions for each session add to your bashrc
# ~/.bashrc or ~/.profile
. <(tk completion)
```
### Options
```
-h, --help help for completion
```
### Options inherited from parent commands
```
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
--kubeconfig string path to the kubeconfig file (default "~/.kube/config")
--namespace string the namespace scope for this operation (default "gitops-system")
--timeout duration timeout for this operation (default 5m0s)
--verbose print generated objects
```
### SEE ALSO
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
###### Auto generated by spf13/cobra on 1-May-2020

@ -29,4 +29,4 @@ Create commands
* [tk create kustomization](tk_create_kustomization.md) - Create or update a kustomization resource * [tk create kustomization](tk_create_kustomization.md) - Create or update a kustomization resource
* [tk create source](tk_create_source.md) - Create source commands * [tk create source](tk_create_source.md) - Create source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -67,4 +67,4 @@ tk create kustomization [name] [flags]
* [tk create](tk_create.md) - Create commands * [tk create](tk_create.md) - Create commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -28,4 +28,4 @@ Create source commands
* [tk create](tk_create.md) - Create commands * [tk create](tk_create.md) - Create commands
* [tk create source git](tk_create_source_git.md) - Create or update a git source * [tk create source git](tk_create_source_git.md) - Create or update a git source
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -71,4 +71,4 @@ tk create source git [name] [flags]
* [tk create source](tk_create_source.md) - Create source commands * [tk create source](tk_create_source.md) - Create source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -10,7 +10,7 @@ Delete commands
``` ```
-h, --help help for delete -h, --help help for delete
--silent delete resource without asking for confirmation -s, --silent delete resource without asking for confirmation
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
@ -29,4 +29,4 @@ Delete commands
* [tk delete kustomization](tk_delete_kustomization.md) - Delete kustomization * [tk delete kustomization](tk_delete_kustomization.md) - Delete kustomization
* [tk delete source](tk_delete_source.md) - Delete sources commands * [tk delete source](tk_delete_source.md) - Delete sources commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -22,7 +22,7 @@ tk delete kustomization [name] [flags]
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller]) --components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
--kubeconfig string path to the kubeconfig file (default "~/.kube/config") --kubeconfig string path to the kubeconfig file (default "~/.kube/config")
--namespace string the namespace scope for this operation (default "gitops-system") --namespace string the namespace scope for this operation (default "gitops-system")
--silent delete resource without asking for confirmation -s, --silent delete resource without asking for confirmation
--timeout duration timeout for this operation (default 5m0s) --timeout duration timeout for this operation (default 5m0s)
--verbose print generated objects --verbose print generated objects
``` ```
@ -31,4 +31,4 @@ tk delete kustomization [name] [flags]
* [tk delete](tk_delete.md) - Delete commands * [tk delete](tk_delete.md) - Delete commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -18,7 +18,7 @@ Delete sources commands
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller]) --components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
--kubeconfig string path to the kubeconfig file (default "~/.kube/config") --kubeconfig string path to the kubeconfig file (default "~/.kube/config")
--namespace string the namespace scope for this operation (default "gitops-system") --namespace string the namespace scope for this operation (default "gitops-system")
--silent delete resource without asking for confirmation -s, --silent delete resource without asking for confirmation
--timeout duration timeout for this operation (default 5m0s) --timeout duration timeout for this operation (default 5m0s)
--verbose print generated objects --verbose print generated objects
``` ```
@ -28,4 +28,4 @@ Delete sources commands
* [tk delete](tk_delete.md) - Delete commands * [tk delete](tk_delete.md) - Delete commands
* [tk delete source git](tk_delete_source_git.md) - Delete git source * [tk delete source git](tk_delete_source_git.md) - Delete git source
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -22,7 +22,7 @@ tk delete source git [name] [flags]
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller]) --components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller])
--kubeconfig string path to the kubeconfig file (default "~/.kube/config") --kubeconfig string path to the kubeconfig file (default "~/.kube/config")
--namespace string the namespace scope for this operation (default "gitops-system") --namespace string the namespace scope for this operation (default "gitops-system")
--silent delete resource without asking for confirmation -s, --silent delete resource without asking for confirmation
--timeout duration timeout for this operation (default 5m0s) --timeout duration timeout for this operation (default 5m0s)
--verbose print generated objects --verbose print generated objects
``` ```
@ -31,4 +31,4 @@ tk delete source git [name] [flags]
* [tk delete source](tk_delete_source.md) - Delete sources commands * [tk delete source](tk_delete_source.md) - Delete sources commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -29,4 +29,4 @@ Export commands
* [tk export kustomization](tk_export_kustomization.md) - Export kustomization in YAML format * [tk export kustomization](tk_export_kustomization.md) - Export kustomization in YAML format
* [tk export source](tk_export_source.md) - Export source commands * [tk export source](tk_export_source.md) - Export source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -42,4 +42,4 @@ tk export kustomization [name] [flags]
* [tk export](tk_export.md) - Export commands * [tk export](tk_export.md) - Export commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -29,4 +29,4 @@ Export source commands
* [tk export](tk_export.md) - Export commands * [tk export](tk_export.md) - Export commands
* [tk export source git](tk_export_source_git.md) - Export git sources in YAML format * [tk export source git](tk_export_source_git.md) - Export git sources in YAML format
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -43,4 +43,4 @@ tk export source git [name] [flags]
* [tk export source](tk_export_source.md) - Export source commands * [tk export source](tk_export_source.md) - Export source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -28,4 +28,4 @@ Get commands
* [tk get kustomizations](tk_get_kustomizations.md) - Get kustomizations status * [tk get kustomizations](tk_get_kustomizations.md) - Get kustomizations status
* [tk get sources](tk_get_sources.md) - Get sources commands * [tk get sources](tk_get_sources.md) - Get sources commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -31,4 +31,4 @@ tk get kustomizations [flags]
* [tk get](tk_get.md) - Get commands * [tk get](tk_get.md) - Get commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -27,4 +27,4 @@ Get sources commands
* [tk get](tk_get.md) - Get commands * [tk get](tk_get.md) - Get commands
* [tk get sources git](tk_get_sources_git.md) - Get git sources status * [tk get sources git](tk_get_sources_git.md) - Get git sources status
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -31,4 +31,4 @@ tk get sources git [flags]
* [tk get sources](tk_get_sources.md) - Get sources commands * [tk get sources](tk_get_sources.md) - Get sources commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -49,4 +49,4 @@ tk install [flags]
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -27,4 +27,4 @@ Resume commands
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
* [tk resume kustomization](tk_resume_kustomization.md) - Resume kustomization * [tk resume kustomization](tk_resume_kustomization.md) - Resume kustomization
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -30,4 +30,4 @@ tk resume kustomization [name] [flags]
* [tk resume](tk_resume.md) - Resume commands * [tk resume](tk_resume.md) - Resume commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -27,4 +27,4 @@ Suspend commands
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
* [tk suspend kustomization](tk_suspend_kustomization.md) - Suspend kustomization * [tk suspend kustomization](tk_suspend_kustomization.md) - Suspend kustomization
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -30,4 +30,4 @@ tk suspend kustomization [name] [flags]
* [tk suspend](tk_suspend.md) - Suspend commands * [tk suspend](tk_suspend.md) - Suspend commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -28,4 +28,4 @@ Synchronize commands
* [tk sync kustomization](tk_sync_kustomization.md) - Synchronize kustomization * [tk sync kustomization](tk_sync_kustomization.md) - Synchronize kustomization
* [tk sync source](tk_sync_source.md) - Synchronize source commands * [tk sync source](tk_sync_source.md) - Synchronize source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -43,4 +43,4 @@ tk sync kustomization [name] [flags]
* [tk sync](tk_sync.md) - Synchronize commands * [tk sync](tk_sync.md) - Synchronize commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -27,4 +27,4 @@ Synchronize source commands
* [tk sync](tk_sync.md) - Synchronize commands * [tk sync](tk_sync.md) - Synchronize commands
* [tk sync source git](tk_sync_source_git.md) - Synchronize git source * [tk sync source git](tk_sync_source_git.md) - Synchronize git source
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -39,4 +39,4 @@ tk sync source git [name] [flags]
* [tk sync source](tk_sync_source.md) - Synchronize source commands * [tk sync source](tk_sync_source.md) - Synchronize source commands
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

@ -29,7 +29,7 @@ tk uninstall [flags]
--crds removes all CRDs previously installed --crds removes all CRDs previously installed
--dry-run only print the object that would be deleted --dry-run only print the object that would be deleted
-h, --help help for uninstall -h, --help help for uninstall
--silent delete components without asking for confirmation -s, --silent delete components without asking for confirmation
``` ```
### Options inherited from parent commands ### Options inherited from parent commands
@ -46,4 +46,4 @@ tk uninstall [flags]
* [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines * [tk](tk.md) - Command line utility for assembling Kubernetes CD pipelines
###### Auto generated by spf13/cobra on 30-Apr-2020 ###### Auto generated by spf13/cobra on 1-May-2020

Loading…
Cancel
Save