init/generate: check that no parameters are passed

This commit is contained in:
Michael Eischer 2023-05-18 19:48:20 +02:00
parent 22c9276719
commit 03b9764bce
2 changed files with 9 additions and 1 deletions

View File

@ -90,7 +90,11 @@ func writePowerShellCompletion(file string) error {
return cmdRoot.GenPowerShellCompletionFile(file)
}
func runGenerate(cmd *cobra.Command, args []string) error {
func runGenerate(_ *cobra.Command, args []string) error {
if len(args) > 0 {
return errors.Fatal("the generate command expects no arguments, only options - please see `restic help generate` for usage and flags")
}
if genOpts.ManDir != "" {
err := writeManpages(genOpts.ManDir)
if err != nil {

View File

@ -50,6 +50,10 @@ func init() {
}
func runInit(ctx context.Context, opts InitOptions, gopts GlobalOptions, args []string) error {
if len(args) > 0 {
return errors.Fatal("the init command expects no arguments, only options - please see `restic help init` for usage and flags")
}
var version uint
if opts.RepositoryVersion == "latest" || opts.RepositoryVersion == "" {
version = restic.MaxRepoVersion