aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel Padrta <64928366+danpadcz@users.noreply.github.com>2024-01-04 11:20:53 +0100
committerGitHub <noreply@github.com>2024-01-04 10:20:53 +0000
commit9387e107b3a8b33b5d4f3a8c1b837e1271cc5cff (patch)
tree9846042263c91a6b28f2c8a7b71b32751530eb88 /cmd
parentaa901790b99e13c6cbf2bb3fda9b8ba3b765d700 (diff)
downloadsyncthing-9387e107b3a8b33b5d4f3a8c1b837e1271cc5cff.tar.gz
syncthing-9387e107b3a8b33b5d4f3a8c1b837e1271cc5cff.zip
cmd/syncthing: Add CLI completion functionality (fixes #8616) (#9226)
### Purpose This implements CLI completion using the Kongplete module. As a side effect a CLI structure for syncthing/cli was created for kongplete to be able to parse and implement CLI completion. ### Testing I've tested the autocompletion manually, and it had worked, but I hadn't added any tests so as to test it automatically. Additionally, I ran `go run build.go test` with all tests passing.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/syncthing/main.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go
index ab3c76e73..6d2216290 100644
--- a/cmd/syncthing/main.go
+++ b/cmd/syncthing/main.go
@@ -32,6 +32,7 @@ import (
"github.com/alecthomas/kong"
"github.com/thejerf/suture/v4"
+ "github.com/willabides/kongplete"
"github.com/syncthing/syncthing/cmd/syncthing/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
@@ -133,10 +134,11 @@ var (
// commands and options here are top level commands to syncthing.
// Cli is just a placeholder for the help text (see main).
var entrypoint struct {
- Serve serveOptions `cmd:"" help:"Run Syncthing"`
- Generate generate.CLI `cmd:"" help:"Generate key and config, then exit"`
- Decrypt decrypt.CLI `cmd:"" help:"Decrypt or verify an encrypted folder"`
- Cli cli.CLI `cmd:"" help:"Command line interface for Syncthing"`
+ Serve serveOptions `cmd:"" help:"Run Syncthing"`
+ Generate generate.CLI `cmd:"" help:"Generate key and config, then exit"`
+ Decrypt decrypt.CLI `cmd:"" help:"Decrypt or verify an encrypted folder"`
+ Cli cli.CLI `cmd:"" help:"Command line interface for Syncthing"`
+ InstallCompletions kongplete.InstallCompletions `cmd:"" help:"Print commands to install shell completions"`
}
// serveOptions are the options for the `syncthing serve` command.
@@ -247,6 +249,7 @@ func main() {
log.Fatal(err)
}
+ kongplete.Complete(parser)
ctx, err := parser.Parse(args)
parser.FatalIfErrorf(err)
ctx.BindTo(l, (*logger.Logger)(nil)) // main logger available to subcommands