move cli flags into AddFlags on option structs

This commit is contained in:
Michael Eischer
2025-02-06 22:10:41 +01:00
parent da47967316
commit dc9b6378f3
24 changed files with 307 additions and 231 deletions
+6 -2
View File
@@ -5,6 +5,7 @@ import (
"github.com/restic/restic/internal/repository"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var unlockCmd = &cobra.Command{
@@ -31,12 +32,15 @@ type UnlockOptions struct {
RemoveAll bool
}
func (opts *UnlockOptions) AddFlags(f *pflag.FlagSet) {
f.BoolVar(&opts.RemoveAll, "remove-all", false, "remove all locks, even non-stale ones")
}
var unlockOptions UnlockOptions
func init() {
cmdRoot.AddCommand(unlockCmd)
unlockCmd.Flags().BoolVar(&unlockOptions.RemoveAll, "remove-all", false, "remove all locks, even non-stale ones")
unlockOptions.AddFlags(unlockCmd.Flags())
}
func runUnlock(ctx context.Context, opts UnlockOptions, gopts GlobalOptions) error {