forked from TrueCloudLab/restic
Merge pull request #5013 from MichaelEischer/group-cli-commands
Group CLI commands and show features/options
This commit is contained in:
commit
5cffd40002
29 changed files with 60 additions and 9 deletions
|
@ -55,6 +55,7 @@ Exit status is 12 if the password is incorrect.
|
|||
backupOptions.Host = hostname
|
||||
}
|
||||
},
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
|
|
|
@ -28,6 +28,7 @@ EXIT STATUS
|
|||
Exit status is 0 if the command was successful.
|
||||
Exit status is 1 if there was any error.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
return runCache(cacheOptions, globalOptions, args)
|
||||
|
|
|
@ -29,6 +29,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runCat(cmd.Context(), globalOptions, args)
|
||||
|
|
|
@ -41,6 +41,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
|
|
|
@ -40,6 +40,8 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runCopy(cmd.Context(), copyOptions, globalOptions, args)
|
||||
},
|
||||
|
|
|
@ -29,8 +29,10 @@ import (
|
|||
)
|
||||
|
||||
var cmdDebug = &cobra.Command{
|
||||
Use: "debug",
|
||||
Short: "Debug commands",
|
||||
Use: "debug",
|
||||
Short: "Debug commands",
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
}
|
||||
|
||||
var cmdDebugDump = &cobra.Command{
|
||||
|
|
|
@ -45,6 +45,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDiff(cmd.Context(), diffOptions, globalOptions, args)
|
||||
|
|
|
@ -40,6 +40,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDump(cmd.Context(), dumpOptions, globalOptions, args)
|
||||
|
|
|
@ -31,7 +31,7 @@ EXIT STATUS
|
|||
Exit status is 0 if the command was successful.
|
||||
Exit status is 1 if there was any error.
|
||||
`,
|
||||
Hidden: true,
|
||||
GroupID: cmdGroupAdvanced,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
if len(args) != 0 {
|
||||
|
|
|
@ -39,6 +39,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runFind(cmd.Context(), findOptions, globalOptions, args)
|
||||
|
|
|
@ -41,6 +41,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
|
|
|
@ -26,6 +26,7 @@ EXIT STATUS
|
|||
Exit status is 0 if the command was successful.
|
||||
Exit status is 1 if there was any error.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runInit(cmd.Context(), initOptions, globalOptions, args)
|
||||
|
|
|
@ -11,6 +11,8 @@ var cmdKey = &cobra.Command{
|
|||
The "key" command allows you to set multiple access keys or passwords
|
||||
per repository.
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
GroupID: cmdGroupDefault,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -26,6 +26,7 @@ Exit status is 11 if the repository is already locked.
|
|||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
GroupID: cmdGroupDefault,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runList(cmd.Context(), globalOptions, args)
|
||||
},
|
||||
|
|
|
@ -46,6 +46,7 @@ Exit status is 11 if the repository is already locked.
|
|||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
GroupID: cmdGroupDefault,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runLs(cmd.Context(), lsOptions, globalOptions, args)
|
||||
},
|
||||
|
|
|
@ -29,6 +29,7 @@ Exit status is 11 if the repository is already locked.
|
|||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
GroupID: cmdGroupDefault,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
defer cancel()
|
||||
|
|
|
@ -71,6 +71,7 @@ Exit status is 11 if the repository is already locked.
|
|||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
GroupID: cmdGroupDefault,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runMount(cmd.Context(), mountOptions, globalOptions, args)
|
||||
},
|
||||
|
|
|
@ -20,7 +20,7 @@ EXIT STATUS
|
|||
Exit status is 0 if the command was successful.
|
||||
Exit status is 1 if there was any error.
|
||||
`,
|
||||
Hidden: true,
|
||||
GroupID: cmdGroupAdvanced,
|
||||
DisableAutoGenTag: true,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Printf("All Extended Options:\n")
|
||||
|
|
|
@ -34,6 +34,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
|
|
|
@ -28,6 +28,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runRecover(cmd.Context(), globalOptions)
|
||||
|
|
|
@ -5,8 +5,10 @@ import (
|
|||
)
|
||||
|
||||
var cmdRepair = &cobra.Command{
|
||||
Use: "repair",
|
||||
Short: "Repair the repository",
|
||||
Use: "repair",
|
||||
Short: "Repair the repository",
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -38,6 +38,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
term, cancel := setupTermstatus()
|
||||
|
|
|
@ -44,6 +44,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runRewrite(cmd.Context(), rewriteOptions, globalOptions, args)
|
||||
|
|
|
@ -29,6 +29,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runSnapshots(cmd.Context(), snapshotOptions, globalOptions, args)
|
||||
|
|
|
@ -55,6 +55,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runStats(cmd.Context(), statsOptions, globalOptions, args)
|
||||
|
|
|
@ -31,6 +31,7 @@ Exit status is 10 if the repository does not exist.
|
|||
Exit status is 11 if the repository is already locked.
|
||||
Exit status is 12 if the password is incorrect.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runTag(cmd.Context(), tagOptions, globalOptions, args)
|
||||
|
|
|
@ -19,6 +19,7 @@ EXIT STATUS
|
|||
Exit status is 0 if the command was successful.
|
||||
Exit status is 1 if there was any error.
|
||||
`,
|
||||
GroupID: cmdGroupDefault,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
return runUnlock(cmd.Context(), unlockOptions, globalOptions)
|
||||
|
|
|
@ -84,6 +84,22 @@ The full documentation can be found at https://restic.readthedocs.io/ .
|
|||
},
|
||||
}
|
||||
|
||||
var cmdGroupDefault = "default"
|
||||
var cmdGroupAdvanced = "advanced"
|
||||
|
||||
func init() {
|
||||
cmdRoot.AddGroup(
|
||||
&cobra.Group{
|
||||
ID: cmdGroupDefault,
|
||||
Title: "Available Commands:",
|
||||
},
|
||||
&cobra.Group{
|
||||
ID: cmdGroupAdvanced,
|
||||
Title: "Advanced Options:",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Distinguish commands that need the password from those that work without,
|
||||
// so we don't run $RESTIC_PASSWORD_COMMAND for no reason (it might prompt the
|
||||
// user for authentication).
|
||||
|
|
|
@ -28,8 +28,6 @@ Usage help is available:
|
|||
dump Print a backed-up file to stdout
|
||||
find Find a file, a directory or restic IDs
|
||||
forget Remove snapshots from the repository
|
||||
generate Generate manual pages and auto-completion files (bash, fish, zsh, powershell)
|
||||
help Help about any command
|
||||
init Initialize a new repository
|
||||
key Manage keys (passwords)
|
||||
list List objects in the repository
|
||||
|
@ -41,11 +39,19 @@ Usage help is available:
|
|||
repair Repair the repository
|
||||
restore Extract the data from a snapshot
|
||||
rewrite Rewrite snapshots to exclude unwanted files
|
||||
self-update Update the restic binary
|
||||
snapshots List all snapshots
|
||||
stats Scan the repository and show basic statistics
|
||||
tag Modify tags on snapshots
|
||||
unlock Remove locks other processes created
|
||||
|
||||
Advanced Options:
|
||||
features Print list of feature flags
|
||||
options Print list of extended options
|
||||
|
||||
Additional Commands:
|
||||
generate Generate manual pages and auto-completion files (bash, fish, zsh, powershell)
|
||||
help Help about any command
|
||||
self-update Update the restic binary
|
||||
version Print version information
|
||||
|
||||
Flags:
|
||||
|
|
Loading…
Reference in a new issue