From 0c4e65228a25baad25eb3d5143868a5a66b226c6 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 7 Feb 2025 20:40:03 +0100 Subject: [PATCH] refactor secondary options --- cmd/restic/cmd_copy.go | 2 +- cmd/restic/cmd_init.go | 2 +- cmd/restic/secondary_repo.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_copy.go b/cmd/restic/cmd_copy.go index cdf688dfa..2ad5a464c 100644 --- a/cmd/restic/cmd_copy.go +++ b/cmd/restic/cmd_copy.go @@ -61,7 +61,7 @@ type CopyOptions struct { } func (opts *CopyOptions) AddFlags(f *pflag.FlagSet) { - initSecondaryRepoOptions(f, &opts.secondaryRepoOptions, "destination", "to copy snapshots from") + opts.secondaryRepoOptions.AddFlags(f, "destination", "to copy snapshots from") initMultiSnapshotFilter(f, &opts.SnapshotFilter, true) } diff --git a/cmd/restic/cmd_init.go b/cmd/restic/cmd_init.go index db2e97c93..d66163af1 100644 --- a/cmd/restic/cmd_init.go +++ b/cmd/restic/cmd_init.go @@ -48,7 +48,7 @@ type InitOptions struct { } func (opts *InitOptions) AddFlags(f *pflag.FlagSet) { - initSecondaryRepoOptions(f, &opts.secondaryRepoOptions, "secondary", "to copy chunker parameters from") + opts.secondaryRepoOptions.AddFlags(f, "secondary", "to copy chunker parameters from") f.BoolVar(&opts.CopyChunkerParameters, "copy-chunker-params", false, "copy chunker parameters from the secondary repository (useful with the copy command)") f.StringVar(&opts.RepositoryVersion, "repository-version", "stable", "repository format version to use, allowed values are a format version, 'latest' and 'stable'") } diff --git a/cmd/restic/secondary_repo.go b/cmd/restic/secondary_repo.go index 66fd4b03b..db4c93bad 100644 --- a/cmd/restic/secondary_repo.go +++ b/cmd/restic/secondary_repo.go @@ -25,7 +25,7 @@ type secondaryRepoOptions struct { LegacyKeyHint string } -func initSecondaryRepoOptions(f *pflag.FlagSet, opts *secondaryRepoOptions, repoPrefix string, repoUsage string) { +func (opts *secondaryRepoOptions) AddFlags(f *pflag.FlagSet, repoPrefix string, repoUsage string) { f.StringVarP(&opts.LegacyRepo, "repo2", "", "", repoPrefix+" `repository` "+repoUsage+" (default: $RESTIC_REPOSITORY2)") f.StringVarP(&opts.LegacyRepositoryFile, "repository-file2", "", "", "`file` from which to read the "+repoPrefix+" repository location "+repoUsage+" (default: $RESTIC_REPOSITORY_FILE2)") f.StringVarP(&opts.LegacyPasswordFile, "password-file2", "", "", "`file` to read the "+repoPrefix+" repository password from (default: $RESTIC_PASSWORD_FILE2)")