`syncthing cli` subcommand was using urfave/cli as the command parser. This PR replace it with kong, which the main command uses. Some help texts and error message format are changed. Other than that, all the command usage and logic remains unchanged. There's only one place which still uses urfave/cli, which is `syncthing cli config`, because it uses some magic to dynamically build commands from struct reflects. I used kong's `passthrough:""` tag to pass any argument following `syncthing cli config` to urfave/cli parser. This PR also fixes #9041 --------- Co-authored-by: Jakob Borg <jakob@kastelo.net>
33 lines
906 B
Go
33 lines
906 B
Go
// Copyright (C) 2014 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
package cli
|
|
|
|
import (
|
|
"github.com/alecthomas/kong"
|
|
)
|
|
|
|
type indexCommand struct {
|
|
Dump struct{} `cmd:"" help:"Print the entire db"`
|
|
DumpSize struct{} `cmd:"" help:"Print the db size of different categories of information"`
|
|
Check struct{} `cmd:"" help:"Check the database for inconsistencies"`
|
|
Account struct{} `cmd:"" help:"Print key and value size statistics per key type"`
|
|
}
|
|
|
|
func (*indexCommand) Run(kongCtx *kong.Context) error {
|
|
switch kongCtx.Selected().Name {
|
|
case "dump":
|
|
return indexDump()
|
|
case "dump-size":
|
|
return indexDumpSize()
|
|
case "check":
|
|
return indexCheck()
|
|
case "account":
|
|
return indexAccount()
|
|
}
|
|
return nil
|
|
}
|