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
125 lines
3.3 KiB
Go
125 lines
3.3 KiB
Go
package flags
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const (
|
|
ContactFN = "contact"
|
|
ContactFolderFN = "contact-folder"
|
|
ContactNameFN = "contact-name"
|
|
|
|
EmailFN = "email"
|
|
EmailFolderFN = "email-folder"
|
|
EmailReceivedAfterFN = "email-received-after"
|
|
EmailReceivedBeforeFN = "email-received-before"
|
|
EmailSenderFN = "email-sender"
|
|
EmailSubjectFN = "email-subject"
|
|
|
|
EventFN = "event"
|
|
EventCalendarFN = "event-calendar"
|
|
EventOrganizerFN = "event-organizer"
|
|
EventRecursFN = "event-recurs"
|
|
EventStartsAfterFN = "event-starts-after"
|
|
EventStartsBeforeFN = "event-starts-before"
|
|
EventSubjectFN = "event-subject"
|
|
)
|
|
|
|
// flag values (ie: FV)
|
|
var (
|
|
ContactFV []string
|
|
ContactFolderFV []string
|
|
ContactNameFV string
|
|
|
|
EmailFV []string
|
|
EmailFolderFV []string
|
|
EmailReceivedAfterFV string
|
|
EmailReceivedBeforeFV string
|
|
EmailSenderFV string
|
|
EmailSubjectFV string
|
|
|
|
EventFV []string
|
|
EventCalendarFV []string
|
|
EventOrganizerFV string
|
|
EventRecursFV string
|
|
EventStartsAfterFV string
|
|
EventStartsBeforeFV string
|
|
EventSubjectFV string
|
|
)
|
|
|
|
// AddExchangeDetailsAndRestoreFlags adds flags that are common to both the
|
|
// details and restore commands.
|
|
func AddExchangeDetailsAndRestoreFlags(cmd *cobra.Command) {
|
|
fs := cmd.Flags()
|
|
|
|
// email flags
|
|
fs.StringSliceVar(
|
|
&EmailFV,
|
|
EmailFN, nil,
|
|
"Select email messages by ID; accepts '"+Wildcard+"' to select all emails.")
|
|
fs.StringSliceVar(
|
|
&EmailFolderFV,
|
|
EmailFolderFN, nil,
|
|
"Select emails within a folder; accepts '"+Wildcard+"' to select all email folders.")
|
|
fs.StringVar(
|
|
&EmailSubjectFV,
|
|
EmailSubjectFN, "",
|
|
"Select emails with a subject containing this value.")
|
|
fs.StringVar(
|
|
&EmailSenderFV,
|
|
EmailSenderFN, "",
|
|
"Select emails from a specific sender.")
|
|
fs.StringVar(
|
|
&EmailReceivedAfterFV,
|
|
EmailReceivedAfterFN, "",
|
|
"Select emails received after this datetime.")
|
|
fs.StringVar(
|
|
&EmailReceivedBeforeFV,
|
|
EmailReceivedBeforeFN, "",
|
|
"Select emails received before this datetime.")
|
|
|
|
// event flags
|
|
fs.StringSliceVar(
|
|
&EventFV,
|
|
EventFN, nil,
|
|
"Select events by event ID; accepts '"+Wildcard+"' to select all events.")
|
|
fs.StringSliceVar(
|
|
&EventCalendarFV,
|
|
EventCalendarFN, nil,
|
|
"Select events under a calendar; accepts '"+Wildcard+"' to select all events.")
|
|
fs.StringVar(
|
|
&EventSubjectFV,
|
|
EventSubjectFN, "",
|
|
"Select events with a subject containing this value.")
|
|
fs.StringVar(
|
|
&EventOrganizerFV,
|
|
EventOrganizerFN, "",
|
|
"Select events from a specific organizer.")
|
|
fs.StringVar(
|
|
&EventRecursFV,
|
|
EventRecursFN, "",
|
|
"Select recurring events. Use `--event-recurs false` to select non-recurring events.")
|
|
fs.StringVar(
|
|
&EventStartsAfterFV,
|
|
EventStartsAfterFN, "",
|
|
"Select events starting after this datetime.")
|
|
fs.StringVar(
|
|
&EventStartsBeforeFV,
|
|
EventStartsBeforeFN, "",
|
|
"Select events starting before this datetime.")
|
|
|
|
// contact flags
|
|
fs.StringSliceVar(
|
|
&ContactFV,
|
|
ContactFN, nil,
|
|
"Select contacts by contact ID; accepts '"+Wildcard+"' to select all contacts.")
|
|
fs.StringSliceVar(
|
|
&ContactFolderFV,
|
|
ContactFolderFN, nil,
|
|
"Select contacts within a folder; accepts '"+Wildcard+"' to select all contact folders.")
|
|
fs.StringVar(
|
|
&ContactNameFV,
|
|
ContactNameFN, "",
|
|
"Select contacts whose contact name contains this value.")
|
|
}
|