Skip to content

Commit

Permalink
Add completion command to generate shell completion via carapace
Browse files Browse the repository at this point in the history
carapace is a command-line completion generator for cobra. Currently bash, fish,
powershell and zsh are officially supported.
The hidden `_carapace` command can be used to generate the completion for other
shells (experimental).
  • Loading branch information
penguwin committed Nov 2, 2021
1 parent 8df7b52 commit ef51e8e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 94 deletions.
6 changes: 5 additions & 1 deletion cmd/knoxite/main.go
@@ -1,7 +1,7 @@
/*
* knoxite
* Copyright (c) 2016-2020, Christian Muehlhaeuser <muesli@gmail.com>
* Copyright (c) 2020, Nicolas Martin <penguwin@penguwin.eu>
* Copyright (c) 2020-2021, Nicolas Martin <penguwin@penguwin.eu>
* Copyright (c) 2020, Matthias Hartmann <mahartma@mahartma.com>
*
* For license see LICENSE
Expand All @@ -18,6 +18,7 @@ import (

shutdown "github.com/klauspost/shutdown2"
"github.com/spf13/cobra"
"github.com/rsteube/carapace"

"github.com/knoxite/knoxite"
"github.com/knoxite/knoxite/cmd/knoxite/config"
Expand Down Expand Up @@ -80,6 +81,9 @@ func main() {
globalOpts.Repo = os.Getenv("KNOXITE_REPOSITORY")
globalOpts.Password = os.Getenv("KNOXITE_PASSWORD")

// add the `completion` command via carapace
carapace.Gen(RootCmd)

if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Expand Up @@ -26,12 +26,13 @@ require (
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/onsi/ginkgo v1.14.2
github.com/onsi/gomega v1.10.3
github.com/pelletier/go-toml v1.9.0
github.com/pelletier/go-toml v1.9.3
github.com/pkg/sftp v1.13.0
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect
github.com/restic/chunker v0.4.0
github.com/rsteube/carapace v0.8.14
github.com/segmentio/go-env v1.1.0 // indirect
github.com/spf13/cobra v1.1.3
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
github.com/studio-b12/gowebdav v0.0.0-20210203212356-8244b5a5f51a
github.com/t3rm1n4l/go-mega v0.0.0-20200416171014-ffad7fcb44b8
Expand All @@ -41,9 +42,8 @@ require (
github.com/ungerik/go-dry v0.0.0-20180411133923-654ae31114c8 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57
golang.org/x/sys v0.0.0-20210510120138-977fb7262007
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
google.golang.org/api v0.44.0
gopkg.in/ini.v1 v1.51.1 // indirect
gopkg.in/kothar/go-backblaze.v0 v0.0.0-20210124194846-35409b867216
)

0 comments on commit ef51e8e

Please sign in to comment.