The goal of this PR is to normalize the cli packages in a way that 1/ showcases clear ownership of data, 2/ minimizes package bloat, and 3/ helps avoid circular import issues. To achieve this, two primary changes were made. First, the cli/options package was folded into cli/utils, so that all "shared functionality" is owned by a single package. Second, all flag values, globals, declarations, and mutator funcs (in the cli layer, logging package was not changed) were extracted from cli/utils and placed into cli/flags. This divides ownership between the declaration and population of the flags (cli/flags) from the utilization of values derived from flags in command processing (cli/utils). This PR contains zero logical changes. Only code movement and renaming. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3664 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
19 lines
355 B
Go
19 lines
355 B
Go
package flags
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const BackupFN = "backup"
|
|
|
|
var BackupIDFV string
|
|
|
|
// AddBackupIDFlag adds the --backup flag.
|
|
func AddBackupIDFlag(cmd *cobra.Command, require bool) {
|
|
cmd.Flags().StringVar(&BackupIDFV, BackupFN, "", "ID of the backup to retrieve.")
|
|
|
|
if require {
|
|
cobra.CheckErr(cmd.MarkFlagRequired(BackupFN))
|
|
}
|
|
}
|