cli naming readability and clarification (#2990)
Appends FV to the shared values populated by cobra flags. This helps ensure those values are not confused by other, like-named values used as func params or local vars. Also amends some other varname issues. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
25cffcdf8d
commit
a6a037df28
@ -148,7 +148,7 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validateExchangeBackupCreateFlags(utils.User, utils.CategoryData); err != nil {
|
||||
if err := validateExchangeBackupCreateFlags(utils.UserFV, utils.CategoryDataFV); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
defer utils.CloseRepo(ctx, r)
|
||||
|
||||
sel := exchangeBackupCreateSelectors(utils.User, utils.CategoryData)
|
||||
sel := exchangeBackupCreateSelectors(utils.UserFV, utils.CategoryDataFV)
|
||||
|
||||
// TODO: log/print recoverable errors
|
||||
errs := fault.New(false)
|
||||
@ -237,7 +237,7 @@ func exchangeListCmd() *cobra.Command {
|
||||
|
||||
// lists the history of backup operations
|
||||
func listExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericListCommand(cmd, utils.BackupID, path.ExchangeService, args)
|
||||
return genericListCommand(cmd, utils.BackupIDFV, path.ExchangeService, args)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -273,7 +273,7 @@ func detailsExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
ctrlOpts := options.Control()
|
||||
|
||||
ds, err := runDetailsExchangeCmd(ctx, r, utils.BackupID, opts, ctrlOpts.SkipReduce)
|
||||
ds, err := runDetailsExchangeCmd(ctx, r, utils.BackupIDFV, opts, ctrlOpts.SkipReduce)
|
||||
if err != nil {
|
||||
return Only(ctx, err)
|
||||
}
|
||||
@ -341,5 +341,5 @@ func exchangeDeleteCmd() *cobra.Command {
|
||||
|
||||
// deletes an exchange service backup.
|
||||
func deleteExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericDeleteCommand(cmd, utils.BackupID, "Exchange", args)
|
||||
return genericDeleteCommand(cmd, utils.BackupIDFV, "Exchange", args)
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validateOneDriveBackupCreateFlags(utils.User); err != nil {
|
||||
if err := validateOneDriveBackupCreateFlags(utils.UserFV); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
defer utils.CloseRepo(ctx, r)
|
||||
|
||||
sel := oneDriveBackupCreateSelectors(utils.User)
|
||||
sel := oneDriveBackupCreateSelectors(utils.UserFV)
|
||||
|
||||
// TODO: log/print recoverable errors
|
||||
errs := fault.New(false)
|
||||
@ -198,7 +198,7 @@ func oneDriveListCmd() *cobra.Command {
|
||||
|
||||
// lists the history of backup operations
|
||||
func listOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericListCommand(cmd, utils.BackupID, path.OneDriveService, args)
|
||||
return genericListCommand(cmd, utils.BackupIDFV, path.OneDriveService, args)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -234,7 +234,7 @@ func detailsOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
ctrlOpts := options.Control()
|
||||
|
||||
ds, err := runDetailsOneDriveCmd(ctx, r, utils.BackupID, opts, ctrlOpts.SkipReduce)
|
||||
ds, err := runDetailsOneDriveCmd(ctx, r, utils.BackupIDFV, opts, ctrlOpts.SkipReduce)
|
||||
if err != nil {
|
||||
return Only(ctx, err)
|
||||
}
|
||||
@ -299,5 +299,5 @@ func oneDriveDeleteCmd() *cobra.Command {
|
||||
|
||||
// deletes a oneDrive service backup.
|
||||
func deleteOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericDeleteCommand(cmd, utils.BackupID, "OneDrive", args)
|
||||
return genericDeleteCommand(cmd, utils.BackupIDFV, "OneDrive", args)
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ func createSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validateSharePointBackupCreateFlags(utils.SiteID, utils.WebURL, utils.CategoryData); err != nil {
|
||||
if err := validateSharePointBackupCreateFlags(utils.SiteIDFV, utils.WebURLFV, utils.CategoryDataFV); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ func createSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
return Only(ctx, clues.Wrap(err, "Failed to connect to Microsoft APIs"))
|
||||
}
|
||||
|
||||
sel, err := sharePointBackupCreateSelectors(ctx, utils.SiteID, utils.WebURL, utils.CategoryData, gc)
|
||||
sel, err := sharePointBackupCreateSelectors(ctx, utils.SiteIDFV, utils.WebURLFV, utils.CategoryDataFV, gc)
|
||||
if err != nil {
|
||||
return Only(ctx, clues.Wrap(err, "Retrieving up sharepoint sites by ID and URL"))
|
||||
}
|
||||
@ -275,7 +275,7 @@ func sharePointListCmd() *cobra.Command {
|
||||
|
||||
// lists the history of backup operations
|
||||
func listSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericListCommand(cmd, utils.BackupID, path.SharePointService, args)
|
||||
return genericListCommand(cmd, utils.BackupIDFV, path.SharePointService, args)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -295,7 +295,7 @@ func sharePointDeleteCmd() *cobra.Command {
|
||||
|
||||
// deletes a sharePoint service backup.
|
||||
func deleteSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
return genericDeleteCommand(cmd, utils.BackupID, "SharePoint", args)
|
||||
return genericDeleteCommand(cmd, utils.BackupIDFV, "SharePoint", args)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -331,7 +331,7 @@ func detailsSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
ctrlOpts := options.Control()
|
||||
|
||||
ds, err := runDetailsSharePointCmd(ctx, r, utils.BackupID, opts, ctrlOpts.SkipReduce)
|
||||
ds, err := runDetailsSharePointCmd(ctx, r, utils.BackupIDFV, opts, ctrlOpts.SkipReduce)
|
||||
if err != nil {
|
||||
return Only(ctx, err)
|
||||
}
|
||||
|
||||
@ -84,11 +84,11 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
opts := utils.MakeExchangeOpts(cmd)
|
||||
|
||||
if utils.RunMode == utils.RunModeFlagTest {
|
||||
if utils.RunModeFV == utils.RunModeFlagTest {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := utils.ValidateExchangeRestoreFlags(utils.BackupID, opts); err != nil {
|
||||
if err := utils.ValidateExchangeRestoreFlags(utils.BackupIDFV, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
sel := utils.IncludeExchangeRestoreDataSelectors(opts)
|
||||
utils.FilterExchangeRestoreInfoSelectors(sel, opts)
|
||||
|
||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||
ro, err := r.NewRestore(ctx, utils.BackupIDFV, sel.Selector, dest)
|
||||
if err != nil {
|
||||
return Only(ctx, clues.Wrap(err, "Failed to initialize Exchange restore"))
|
||||
}
|
||||
@ -118,7 +118,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
||||
ds, err := ro.Run(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, data.ErrNotFound) {
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupIDFV))
|
||||
}
|
||||
|
||||
return Only(ctx, clues.Wrap(err, "Failed to run Exchange restore"))
|
||||
|
||||
@ -60,26 +60,26 @@ func (suite *ExchangeUnitSuite) TestAddExchangeCommands() {
|
||||
cmd.SetArgs([]string{
|
||||
"exchange",
|
||||
"--" + utils.RunModeFN, utils.RunModeFlagTest,
|
||||
"--" + utils.BackupFN, testdata.BackupInpt,
|
||||
"--" + utils.BackupFN, testdata.BackupInput,
|
||||
|
||||
"--" + utils.ContactFN, testdata.FlgInpts(testdata.ContactInpt),
|
||||
"--" + utils.ContactFolderFN, testdata.FlgInpts(testdata.ContactFldInpt),
|
||||
"--" + utils.ContactNameFN, testdata.ContactNameInpt,
|
||||
"--" + utils.ContactFN, testdata.FlgInputs(testdata.ContactInput),
|
||||
"--" + utils.ContactFolderFN, testdata.FlgInputs(testdata.ContactFldInput),
|
||||
"--" + utils.ContactNameFN, testdata.ContactNameInput,
|
||||
|
||||
"--" + utils.EmailFN, testdata.FlgInpts(testdata.EmailInpt),
|
||||
"--" + utils.EmailFolderFN, testdata.FlgInpts(testdata.EmailFldInpt),
|
||||
"--" + utils.EmailReceivedAfterFN, testdata.EmailReceivedAfterInpt,
|
||||
"--" + utils.EmailReceivedBeforeFN, testdata.EmailReceivedBeforeInpt,
|
||||
"--" + utils.EmailSenderFN, testdata.EmailSenderInpt,
|
||||
"--" + utils.EmailSubjectFN, testdata.EmailSubjectInpt,
|
||||
"--" + utils.EmailFN, testdata.FlgInputs(testdata.EmailInput),
|
||||
"--" + utils.EmailFolderFN, testdata.FlgInputs(testdata.EmailFldInput),
|
||||
"--" + utils.EmailReceivedAfterFN, testdata.EmailReceivedAfterInput,
|
||||
"--" + utils.EmailReceivedBeforeFN, testdata.EmailReceivedBeforeInput,
|
||||
"--" + utils.EmailSenderFN, testdata.EmailSenderInput,
|
||||
"--" + utils.EmailSubjectFN, testdata.EmailSubjectInput,
|
||||
|
||||
"--" + utils.EventFN, testdata.FlgInpts(testdata.EventInpt),
|
||||
"--" + utils.EventCalendarFN, testdata.FlgInpts(testdata.EventCalInpt),
|
||||
"--" + utils.EventOrganizerFN, testdata.EventOrganizerInpt,
|
||||
"--" + utils.EventRecursFN, testdata.EventRecursInpt,
|
||||
"--" + utils.EventStartsAfterFN, testdata.EventStartsAfterInpt,
|
||||
"--" + utils.EventStartsBeforeFN, testdata.EventStartsBeforeInpt,
|
||||
"--" + utils.EventSubjectFN, testdata.EventSubjectInpt,
|
||||
"--" + utils.EventFN, testdata.FlgInputs(testdata.EventInput),
|
||||
"--" + utils.EventCalendarFN, testdata.FlgInputs(testdata.EventCalInput),
|
||||
"--" + utils.EventOrganizerFN, testdata.EventOrganizerInput,
|
||||
"--" + utils.EventRecursFN, testdata.EventRecursInput,
|
||||
"--" + utils.EventStartsAfterFN, testdata.EventStartsAfterInput,
|
||||
"--" + utils.EventStartsBeforeFN, testdata.EventStartsBeforeInput,
|
||||
"--" + utils.EventSubjectFN, testdata.EventSubjectInput,
|
||||
})
|
||||
|
||||
cmd.SetOut(new(bytes.Buffer)) // drop output
|
||||
@ -88,26 +88,26 @@ func (suite *ExchangeUnitSuite) TestAddExchangeCommands() {
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
opts := utils.MakeExchangeOpts(cmd)
|
||||
assert.Equal(t, testdata.BackupInpt, utils.BackupID)
|
||||
assert.Equal(t, testdata.BackupInput, utils.BackupIDFV)
|
||||
|
||||
assert.ElementsMatch(t, testdata.ContactInpt, opts.Contact)
|
||||
assert.ElementsMatch(t, testdata.ContactFldInpt, opts.ContactFolder)
|
||||
assert.Equal(t, testdata.ContactNameInpt, opts.ContactName)
|
||||
assert.ElementsMatch(t, testdata.ContactInput, opts.Contact)
|
||||
assert.ElementsMatch(t, testdata.ContactFldInput, opts.ContactFolder)
|
||||
assert.Equal(t, testdata.ContactNameInput, opts.ContactName)
|
||||
|
||||
assert.ElementsMatch(t, testdata.EmailInpt, opts.Email)
|
||||
assert.ElementsMatch(t, testdata.EmailFldInpt, opts.EmailFolder)
|
||||
assert.Equal(t, testdata.EmailReceivedAfterInpt, opts.EmailReceivedAfter)
|
||||
assert.Equal(t, testdata.EmailReceivedBeforeInpt, opts.EmailReceivedBefore)
|
||||
assert.Equal(t, testdata.EmailSenderInpt, opts.EmailSender)
|
||||
assert.Equal(t, testdata.EmailSubjectInpt, opts.EmailSubject)
|
||||
assert.ElementsMatch(t, testdata.EmailInput, opts.Email)
|
||||
assert.ElementsMatch(t, testdata.EmailFldInput, opts.EmailFolder)
|
||||
assert.Equal(t, testdata.EmailReceivedAfterInput, opts.EmailReceivedAfter)
|
||||
assert.Equal(t, testdata.EmailReceivedBeforeInput, opts.EmailReceivedBefore)
|
||||
assert.Equal(t, testdata.EmailSenderInput, opts.EmailSender)
|
||||
assert.Equal(t, testdata.EmailSubjectInput, opts.EmailSubject)
|
||||
|
||||
assert.ElementsMatch(t, testdata.EventInpt, opts.Event)
|
||||
assert.ElementsMatch(t, testdata.EventCalInpt, opts.EventCalendar)
|
||||
assert.Equal(t, testdata.EventOrganizerInpt, opts.EventOrganizer)
|
||||
assert.Equal(t, testdata.EventRecursInpt, opts.EventRecurs)
|
||||
assert.Equal(t, testdata.EventStartsAfterInpt, opts.EventStartsAfter)
|
||||
assert.Equal(t, testdata.EventStartsBeforeInpt, opts.EventStartsBefore)
|
||||
assert.Equal(t, testdata.EventSubjectInpt, opts.EventSubject)
|
||||
assert.ElementsMatch(t, testdata.EventInput, opts.Event)
|
||||
assert.ElementsMatch(t, testdata.EventCalInput, opts.EventCalendar)
|
||||
assert.Equal(t, testdata.EventOrganizerInput, opts.EventOrganizer)
|
||||
assert.Equal(t, testdata.EventRecursInput, opts.EventRecurs)
|
||||
assert.Equal(t, testdata.EventStartsAfterInput, opts.EventStartsAfter)
|
||||
assert.Equal(t, testdata.EventStartsBeforeInput, opts.EventStartsBefore)
|
||||
assert.Equal(t, testdata.EventSubjectInput, opts.EventSubject)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,11 +86,11 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
opts := utils.MakeOneDriveOpts(cmd)
|
||||
|
||||
if utils.RunMode == utils.RunModeFlagTest {
|
||||
if utils.RunModeFV == utils.RunModeFlagTest {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := utils.ValidateOneDriveRestoreFlags(utils.BackupID, opts); err != nil {
|
||||
if err := utils.ValidateOneDriveRestoreFlags(utils.BackupIDFV, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
sel := utils.IncludeOneDriveRestoreDataSelectors(opts)
|
||||
utils.FilterOneDriveRestoreInfoSelectors(sel, opts)
|
||||
|
||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||
ro, err := r.NewRestore(ctx, utils.BackupIDFV, sel.Selector, dest)
|
||||
if err != nil {
|
||||
return Only(ctx, clues.Wrap(err, "Failed to initialize OneDrive restore"))
|
||||
}
|
||||
@ -120,7 +120,7 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
||||
ds, err := ro.Run(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, data.ErrNotFound) {
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupIDFV))
|
||||
}
|
||||
|
||||
return Only(ctx, clues.Wrap(err, "Failed to run OneDrive restore"))
|
||||
|
||||
@ -59,14 +59,14 @@ func (suite *OneDriveUnitSuite) TestAddOneDriveCommands() {
|
||||
cmd.SetArgs([]string{
|
||||
"onedrive",
|
||||
"--" + utils.RunModeFN, utils.RunModeFlagTest,
|
||||
"--" + utils.BackupFN, testdata.BackupInpt,
|
||||
"--" + utils.BackupFN, testdata.BackupInput,
|
||||
|
||||
"--" + utils.FileFN, testdata.FlgInpts(testdata.FileNamesInpt),
|
||||
"--" + utils.FolderFN, testdata.FlgInpts(testdata.FolderPathsInpt),
|
||||
"--" + utils.FileCreatedAfterFN, testdata.FileCreatedAfterInpt,
|
||||
"--" + utils.FileCreatedBeforeFN, testdata.FileCreatedBeforeInpt,
|
||||
"--" + utils.FileModifiedAfterFN, testdata.FileModifiedAfterInpt,
|
||||
"--" + utils.FileModifiedBeforeFN, testdata.FileModifiedBeforeInpt,
|
||||
"--" + utils.FileFN, testdata.FlgInputs(testdata.FileNameInput),
|
||||
"--" + utils.FolderFN, testdata.FlgInputs(testdata.FolderPathInput),
|
||||
"--" + utils.FileCreatedAfterFN, testdata.FileCreatedAfterInput,
|
||||
"--" + utils.FileCreatedBeforeFN, testdata.FileCreatedBeforeInput,
|
||||
"--" + utils.FileModifiedAfterFN, testdata.FileModifiedAfterInput,
|
||||
"--" + utils.FileModifiedBeforeFN, testdata.FileModifiedBeforeInput,
|
||||
})
|
||||
|
||||
cmd.SetOut(new(bytes.Buffer)) // drop output
|
||||
@ -75,14 +75,14 @@ func (suite *OneDriveUnitSuite) TestAddOneDriveCommands() {
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
opts := utils.MakeOneDriveOpts(cmd)
|
||||
assert.Equal(t, testdata.BackupInpt, utils.BackupID)
|
||||
assert.Equal(t, testdata.BackupInput, utils.BackupIDFV)
|
||||
|
||||
assert.ElementsMatch(t, testdata.FileNamesInpt, opts.FileNames)
|
||||
assert.ElementsMatch(t, testdata.FolderPathsInpt, opts.FolderPaths)
|
||||
assert.Equal(t, testdata.FileCreatedAfterInpt, opts.FileCreatedAfter)
|
||||
assert.Equal(t, testdata.FileCreatedBeforeInpt, opts.FileCreatedBefore)
|
||||
assert.Equal(t, testdata.FileModifiedAfterInpt, opts.FileModifiedAfter)
|
||||
assert.Equal(t, testdata.FileModifiedBeforeInpt, opts.FileModifiedBefore)
|
||||
assert.ElementsMatch(t, testdata.FileNameInput, opts.FileName)
|
||||
assert.ElementsMatch(t, testdata.FolderPathInput, opts.FolderPath)
|
||||
assert.Equal(t, testdata.FileCreatedAfterInput, opts.FileCreatedAfter)
|
||||
assert.Equal(t, testdata.FileCreatedBeforeInput, opts.FileCreatedBefore)
|
||||
assert.Equal(t, testdata.FileModifiedAfterInput, opts.FileModifiedAfter)
|
||||
assert.Equal(t, testdata.FileModifiedBeforeInput, opts.FileModifiedBefore)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
|
||||
opts := utils.MakeSharePointOpts(cmd)
|
||||
|
||||
if utils.RunMode == utils.RunModeFlagTest {
|
||||
if utils.RunModeFV == utils.RunModeFlagTest {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := utils.ValidateSharePointRestoreFlags(utils.BackupID, opts); err != nil {
|
||||
if err := utils.ValidateSharePointRestoreFlags(utils.BackupIDFV, opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
sel := utils.IncludeSharePointRestoreDataSelectors(opts)
|
||||
utils.FilterSharePointRestoreInfoSelectors(sel, opts)
|
||||
|
||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||
ro, err := r.NewRestore(ctx, utils.BackupIDFV, sel.Selector, dest)
|
||||
if err != nil {
|
||||
return Only(ctx, clues.Wrap(err, "Failed to initialize SharePoint restore"))
|
||||
}
|
||||
@ -119,7 +119,7 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
ds, err := ro.Run(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, data.ErrNotFound) {
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupIDFV))
|
||||
}
|
||||
|
||||
return Only(ctx, clues.Wrap(err, "Failed to run SharePoint restore"))
|
||||
|
||||
@ -59,21 +59,21 @@ func (suite *SharePointUnitSuite) TestAddSharePointCommands() {
|
||||
cmd.SetArgs([]string{
|
||||
"sharepoint",
|
||||
"--" + utils.RunModeFN, utils.RunModeFlagTest,
|
||||
"--" + utils.BackupFN, testdata.BackupInpt,
|
||||
"--" + utils.BackupFN, testdata.BackupInput,
|
||||
|
||||
"--" + utils.LibraryFN, testdata.LibraryInpt,
|
||||
"--" + utils.FileFN, testdata.FlgInpts(testdata.FileNamesInpt),
|
||||
"--" + utils.FolderFN, testdata.FlgInpts(testdata.FolderPathsInpt),
|
||||
"--" + utils.FileCreatedAfterFN, testdata.FileCreatedAfterInpt,
|
||||
"--" + utils.FileCreatedBeforeFN, testdata.FileCreatedBeforeInpt,
|
||||
"--" + utils.FileModifiedAfterFN, testdata.FileModifiedAfterInpt,
|
||||
"--" + utils.FileModifiedBeforeFN, testdata.FileModifiedBeforeInpt,
|
||||
"--" + utils.LibraryFN, testdata.LibraryInput,
|
||||
"--" + utils.FileFN, testdata.FlgInputs(testdata.FileNameInput),
|
||||
"--" + utils.FolderFN, testdata.FlgInputs(testdata.FolderPathInput),
|
||||
"--" + utils.FileCreatedAfterFN, testdata.FileCreatedAfterInput,
|
||||
"--" + utils.FileCreatedBeforeFN, testdata.FileCreatedBeforeInput,
|
||||
"--" + utils.FileModifiedAfterFN, testdata.FileModifiedAfterInput,
|
||||
"--" + utils.FileModifiedBeforeFN, testdata.FileModifiedBeforeInput,
|
||||
|
||||
"--" + utils.ListItemFN, testdata.FlgInpts(testdata.ListItemInpt),
|
||||
"--" + utils.ListFolderFN, testdata.FlgInpts(testdata.ListFolderInpt),
|
||||
"--" + utils.ListItemFN, testdata.FlgInputs(testdata.ListItemInput),
|
||||
"--" + utils.ListFolderFN, testdata.FlgInputs(testdata.ListFolderInput),
|
||||
|
||||
"--" + utils.PageFN, testdata.FlgInpts(testdata.PageInpt),
|
||||
"--" + utils.PageFolderFN, testdata.FlgInpts(testdata.PageFolderInpt),
|
||||
"--" + utils.PageFN, testdata.FlgInputs(testdata.PageInput),
|
||||
"--" + utils.PageFolderFN, testdata.FlgInputs(testdata.PageFolderInput),
|
||||
})
|
||||
|
||||
cmd.SetOut(new(bytes.Buffer)) // drop output
|
||||
@ -82,21 +82,21 @@ func (suite *SharePointUnitSuite) TestAddSharePointCommands() {
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
opts := utils.MakeSharePointOpts(cmd)
|
||||
assert.Equal(t, testdata.BackupInpt, utils.BackupID)
|
||||
assert.Equal(t, testdata.BackupInput, utils.BackupIDFV)
|
||||
|
||||
assert.Equal(t, testdata.LibraryInpt, opts.Library)
|
||||
assert.ElementsMatch(t, testdata.FileNamesInpt, opts.FileName)
|
||||
assert.ElementsMatch(t, testdata.FolderPathsInpt, opts.FolderPath)
|
||||
assert.Equal(t, testdata.FileCreatedAfterInpt, opts.FileCreatedAfter)
|
||||
assert.Equal(t, testdata.FileCreatedBeforeInpt, opts.FileCreatedBefore)
|
||||
assert.Equal(t, testdata.FileModifiedAfterInpt, opts.FileModifiedAfter)
|
||||
assert.Equal(t, testdata.FileModifiedBeforeInpt, opts.FileModifiedBefore)
|
||||
assert.Equal(t, testdata.LibraryInput, opts.Library)
|
||||
assert.ElementsMatch(t, testdata.FileNameInput, opts.FileName)
|
||||
assert.ElementsMatch(t, testdata.FolderPathInput, opts.FolderPath)
|
||||
assert.Equal(t, testdata.FileCreatedAfterInput, opts.FileCreatedAfter)
|
||||
assert.Equal(t, testdata.FileCreatedBeforeInput, opts.FileCreatedBefore)
|
||||
assert.Equal(t, testdata.FileModifiedAfterInput, opts.FileModifiedAfter)
|
||||
assert.Equal(t, testdata.FileModifiedBeforeInput, opts.FileModifiedBefore)
|
||||
|
||||
assert.ElementsMatch(t, testdata.ListItemInpt, opts.ListItem)
|
||||
assert.ElementsMatch(t, testdata.ListFolderInpt, opts.ListFolder)
|
||||
assert.ElementsMatch(t, testdata.ListItemInput, opts.ListItem)
|
||||
assert.ElementsMatch(t, testdata.ListFolderInput, opts.ListFolder)
|
||||
|
||||
assert.ElementsMatch(t, testdata.PageInpt, opts.Page)
|
||||
assert.ElementsMatch(t, testdata.PageFolderInpt, opts.PageFolder)
|
||||
assert.ElementsMatch(t, testdata.PageInput, opts.Page)
|
||||
assert.ElementsMatch(t, testdata.PageFolderInput, opts.PageFolder)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
)
|
||||
|
||||
// flag names
|
||||
// flag names (id: FN)
|
||||
const (
|
||||
ContactFN = "contact"
|
||||
ContactFolderFN = "contact-folder"
|
||||
@ -29,26 +29,26 @@ const (
|
||||
EventSubjectFN = "event-subject"
|
||||
)
|
||||
|
||||
// flag population values
|
||||
// flag values (ie: FV)
|
||||
var (
|
||||
Contact []string
|
||||
ContactFolder []string
|
||||
ContactName string
|
||||
ContactFV []string
|
||||
ContactFolderFV []string
|
||||
ContactNameFV string
|
||||
|
||||
Email []string
|
||||
EmailFolder []string
|
||||
EmailReceivedAfter string
|
||||
EmailReceivedBefore string
|
||||
EmailSender string
|
||||
EmailSubject string
|
||||
EmailFV []string
|
||||
EmailFolderFV []string
|
||||
EmailReceivedAfterFV string
|
||||
EmailReceivedBeforeFV string
|
||||
EmailSenderFV string
|
||||
EmailSubjectFV string
|
||||
|
||||
Event []string
|
||||
EventCalendar []string
|
||||
EventOrganizer string
|
||||
EventRecurs string
|
||||
EventStartsAfter string
|
||||
EventStartsBefore string
|
||||
EventSubject string
|
||||
EventFV []string
|
||||
EventCalendarFV []string
|
||||
EventOrganizerFV string
|
||||
EventRecursFV string
|
||||
EventStartsAfterFV string
|
||||
EventStartsBeforeFV string
|
||||
EventSubjectFV string
|
||||
)
|
||||
|
||||
type ExchangeOpts struct {
|
||||
@ -79,26 +79,26 @@ type ExchangeOpts struct {
|
||||
// populates an ExchangeOpts struct with the command's current flags.
|
||||
func MakeExchangeOpts(cmd *cobra.Command) ExchangeOpts {
|
||||
return ExchangeOpts{
|
||||
Users: User,
|
||||
Users: UserFV,
|
||||
|
||||
Contact: Contact,
|
||||
ContactFolder: ContactFolder,
|
||||
ContactName: ContactName,
|
||||
Contact: ContactFV,
|
||||
ContactFolder: ContactFolderFV,
|
||||
ContactName: ContactNameFV,
|
||||
|
||||
Email: Email,
|
||||
EmailFolder: EmailFolder,
|
||||
EmailReceivedAfter: EmailReceivedAfter,
|
||||
EmailReceivedBefore: EmailReceivedBefore,
|
||||
EmailSender: EmailSender,
|
||||
EmailSubject: EmailSubject,
|
||||
Email: EmailFV,
|
||||
EmailFolder: EmailFolderFV,
|
||||
EmailReceivedAfter: EmailReceivedAfterFV,
|
||||
EmailReceivedBefore: EmailReceivedBeforeFV,
|
||||
EmailSender: EmailSenderFV,
|
||||
EmailSubject: EmailSubjectFV,
|
||||
|
||||
Event: Event,
|
||||
EventCalendar: EventCalendar,
|
||||
EventOrganizer: EventOrganizer,
|
||||
EventRecurs: EventRecurs,
|
||||
EventStartsAfter: EventStartsAfter,
|
||||
EventStartsBefore: EventStartsBefore,
|
||||
EventSubject: EventSubject,
|
||||
Event: EventFV,
|
||||
EventCalendar: EventCalendarFV,
|
||||
EventOrganizer: EventOrganizerFV,
|
||||
EventRecurs: EventRecursFV,
|
||||
EventStartsAfter: EventStartsAfterFV,
|
||||
EventStartsBefore: EventStartsBeforeFV,
|
||||
EventSubject: EventSubjectFV,
|
||||
|
||||
Populated: GetPopulatedFlags(cmd),
|
||||
}
|
||||
@ -111,71 +111,71 @@ func AddExchangeDetailsAndRestoreFlags(cmd *cobra.Command) {
|
||||
|
||||
// email flags
|
||||
fs.StringSliceVar(
|
||||
&Email,
|
||||
&EmailFV,
|
||||
EmailFN, nil,
|
||||
"Select emails by email ID; accepts '"+Wildcard+"' to select all emails.")
|
||||
fs.StringSliceVar(
|
||||
&EmailFolder,
|
||||
&EmailFolderFV,
|
||||
EmailFolderFN, nil,
|
||||
"Select emails within a folder; accepts '"+Wildcard+"' to select all email folders.")
|
||||
fs.StringVar(
|
||||
&EmailSubject,
|
||||
&EmailSubjectFV,
|
||||
EmailSubjectFN, "",
|
||||
"Select emails with a subject containing this value.")
|
||||
fs.StringVar(
|
||||
&EmailSender,
|
||||
&EmailSenderFV,
|
||||
EmailSenderFN, "",
|
||||
"Select emails from a specific sender.")
|
||||
fs.StringVar(
|
||||
&EmailReceivedAfter,
|
||||
&EmailReceivedAfterFV,
|
||||
EmailReceivedAfterFN, "",
|
||||
"Select emails received after this datetime.")
|
||||
fs.StringVar(
|
||||
&EmailReceivedBefore,
|
||||
&EmailReceivedBeforeFV,
|
||||
EmailReceivedBeforeFN, "",
|
||||
"Select emails received before this datetime.")
|
||||
|
||||
// event flags
|
||||
fs.StringSliceVar(
|
||||
&Event,
|
||||
&EventFV,
|
||||
EventFN, nil,
|
||||
"Select events by event ID; accepts '"+Wildcard+"' to select all events.")
|
||||
fs.StringSliceVar(
|
||||
&EventCalendar,
|
||||
&EventCalendarFV,
|
||||
EventCalendarFN, nil,
|
||||
"Select events under a calendar; accepts '"+Wildcard+"' to select all events.")
|
||||
fs.StringVar(
|
||||
&EventSubject,
|
||||
&EventSubjectFV,
|
||||
EventSubjectFN, "",
|
||||
"Select events with a subject containing this value.")
|
||||
fs.StringVar(
|
||||
&EventOrganizer,
|
||||
&EventOrganizerFV,
|
||||
EventOrganizerFN, "",
|
||||
"Select events from a specific organizer.")
|
||||
fs.StringVar(
|
||||
&EventRecurs,
|
||||
&EventRecursFV,
|
||||
EventRecursFN, "",
|
||||
"Select recurring events. Use `--event-recurs false` to select non-recurring events.")
|
||||
fs.StringVar(
|
||||
&EventStartsAfter,
|
||||
&EventStartsAfterFV,
|
||||
EventStartsAfterFN, "",
|
||||
"Select events starting after this datetime.")
|
||||
fs.StringVar(
|
||||
&EventStartsBefore,
|
||||
&EventStartsBeforeFV,
|
||||
EventStartsBeforeFN, "",
|
||||
"Select events starting before this datetime.")
|
||||
|
||||
// contact flags
|
||||
fs.StringSliceVar(
|
||||
&Contact,
|
||||
&ContactFV,
|
||||
ContactFN, nil,
|
||||
"Select contacts by contact ID; accepts '"+Wildcard+"' to select all contacts.")
|
||||
fs.StringSliceVar(
|
||||
&ContactFolder,
|
||||
&ContactFolderFV,
|
||||
ContactFolderFN, nil,
|
||||
"Select contacts within a folder; accepts '"+Wildcard+"' to select all contact folders.")
|
||||
fs.StringVar(
|
||||
&ContactName,
|
||||
&ContactNameFV,
|
||||
ContactNameFN, "",
|
||||
"Select contacts whose contact name contains this value.")
|
||||
}
|
||||
|
||||
@ -12,33 +12,33 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
|
||||
// common flag vars
|
||||
// common flag vars (eg: FV)
|
||||
var (
|
||||
// RunMode describes the type of run, such as:
|
||||
// flagtest, dry, run. Should default to 'run'.
|
||||
RunMode string
|
||||
RunModeFV string
|
||||
|
||||
BackupID string
|
||||
BackupIDFV string
|
||||
|
||||
FolderPath []string
|
||||
FileName []string
|
||||
FolderPathFV []string
|
||||
FileNameFV []string
|
||||
|
||||
FileCreatedAfter string
|
||||
FileCreatedBefore string
|
||||
FileModifiedAfter string
|
||||
FileModifiedBefore string
|
||||
FileCreatedAfterFV string
|
||||
FileCreatedBeforeFV string
|
||||
FileModifiedAfterFV string
|
||||
FileModifiedBeforeFV string
|
||||
|
||||
Library string
|
||||
SiteID []string
|
||||
WebURL []string
|
||||
LibraryFV string
|
||||
SiteIDFV []string
|
||||
WebURLFV []string
|
||||
|
||||
User []string
|
||||
UserFV []string
|
||||
|
||||
// for selection of data by category. eg: `--data email,contacts`
|
||||
CategoryData []string
|
||||
CategoryDataFV []string
|
||||
)
|
||||
|
||||
// common flag names
|
||||
// common flag names (eg: FN)
|
||||
const (
|
||||
RunModeFN = "run-mode"
|
||||
|
||||
@ -67,7 +67,7 @@ const (
|
||||
|
||||
// AddBackupIDFlag adds the --backup flag.
|
||||
func AddBackupIDFlag(cmd *cobra.Command, require bool) {
|
||||
cmd.Flags().StringVar(&BackupID, BackupFN, "", "ID of the backup to retrieve.")
|
||||
cmd.Flags().StringVar(&BackupIDFV, BackupFN, "", "ID of the backup to retrieve.")
|
||||
|
||||
if require {
|
||||
cobra.CheckErr(cmd.MarkFlagRequired(BackupFN))
|
||||
@ -95,7 +95,7 @@ func AddDataFlag(cmd *cobra.Command, allowed []string, hide bool) {
|
||||
}
|
||||
|
||||
fs.StringSliceVar(
|
||||
&CategoryData,
|
||||
&CategoryDataFV,
|
||||
CategoryDataFN, nil,
|
||||
"Select one or more types of data to backup: "+allowedMsg+".")
|
||||
|
||||
@ -111,14 +111,14 @@ func AddRunModeFlag(cmd *cobra.Command, persistent bool) {
|
||||
fs = cmd.PersistentFlags()
|
||||
}
|
||||
|
||||
fs.StringVar(&RunMode, RunModeFN, "run", "What mode to run: dry, test, run. Defaults to run.")
|
||||
fs.StringVar(&RunModeFV, RunModeFN, "run", "What mode to run: dry, test, run. Defaults to run.")
|
||||
cobra.CheckErr(fs.MarkHidden(RunModeFN))
|
||||
}
|
||||
|
||||
// AddUserFlag adds the --user flag.
|
||||
func AddUserFlag(cmd *cobra.Command) {
|
||||
cmd.Flags().StringSliceVar(
|
||||
&User,
|
||||
&UserFV,
|
||||
UserFN, nil,
|
||||
"Backup a specific user's data; accepts '"+Wildcard+"' to select all users.")
|
||||
cobra.CheckErr(cmd.MarkFlagRequired(UserFN))
|
||||
@ -134,7 +134,7 @@ func AddSiteIDFlag(cmd *cobra.Command) {
|
||||
// duplicate values within a flag declaration. ie: --site-id a,b,c does not
|
||||
// work. Users must call --site-id a --site-id b --site-id c.
|
||||
fs.StringArrayVar(
|
||||
&SiteID,
|
||||
&SiteIDFV,
|
||||
SiteIDFN, nil,
|
||||
//nolint:lll
|
||||
"Backup data by site ID; accepts '"+Wildcard+"' to select all sites. Args cannot be comma-delimited and must use multiple flags.")
|
||||
@ -144,7 +144,7 @@ func AddSiteIDFlag(cmd *cobra.Command) {
|
||||
// AddSiteFlag adds the --site flag, which accepts webURL values.
|
||||
func AddSiteFlag(cmd *cobra.Command) {
|
||||
cmd.Flags().StringSliceVar(
|
||||
&WebURL,
|
||||
&WebURLFV,
|
||||
SiteFN, nil,
|
||||
"Backup data by site URL; accepts '"+Wildcard+"' to select all sites.")
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@ import (
|
||||
type OneDriveOpts struct {
|
||||
Users []string
|
||||
|
||||
FileNames []string
|
||||
FolderPaths []string
|
||||
FileName []string
|
||||
FolderPath []string
|
||||
FileCreatedAfter string
|
||||
FileCreatedBefore string
|
||||
FileModifiedAfter string
|
||||
@ -22,14 +22,14 @@ type OneDriveOpts struct {
|
||||
|
||||
func MakeOneDriveOpts(cmd *cobra.Command) OneDriveOpts {
|
||||
return OneDriveOpts{
|
||||
Users: User,
|
||||
Users: UserFV,
|
||||
|
||||
FileNames: FileName,
|
||||
FolderPaths: FolderPath,
|
||||
FileCreatedAfter: FileCreatedAfter,
|
||||
FileCreatedBefore: FileCreatedBefore,
|
||||
FileModifiedAfter: FileModifiedAfter,
|
||||
FileModifiedBefore: FileModifiedBefore,
|
||||
FileName: FileNameFV,
|
||||
FolderPath: FolderPathFV,
|
||||
FileCreatedAfter: FileCreatedAfterFV,
|
||||
FileCreatedBefore: FileCreatedBeforeFV,
|
||||
FileModifiedAfter: FileModifiedAfterFV,
|
||||
FileModifiedBefore: FileModifiedBeforeFV,
|
||||
|
||||
Populated: GetPopulatedFlags(cmd),
|
||||
}
|
||||
@ -41,31 +41,31 @@ func AddOneDriveDetailsAndRestoreFlags(cmd *cobra.Command) {
|
||||
fs := cmd.Flags()
|
||||
|
||||
fs.StringSliceVar(
|
||||
&FolderPath,
|
||||
&FolderPathFV,
|
||||
FolderFN, nil,
|
||||
"Select files by OneDrive folder; defaults to root.")
|
||||
|
||||
fs.StringSliceVar(
|
||||
&FileName,
|
||||
&FileNameFV,
|
||||
FileFN, nil,
|
||||
"Select files by name.")
|
||||
|
||||
fs.StringVar(
|
||||
&FileCreatedAfter,
|
||||
&FileCreatedAfterFV,
|
||||
FileCreatedAfterFN, "",
|
||||
"Select files created after this datetime.")
|
||||
fs.StringVar(
|
||||
&FileCreatedBefore,
|
||||
&FileCreatedBeforeFV,
|
||||
FileCreatedBeforeFN, "",
|
||||
"Select files created before this datetime.")
|
||||
|
||||
fs.StringVar(
|
||||
&FileModifiedAfter,
|
||||
&FileModifiedAfterFV,
|
||||
FileModifiedAfterFN, "",
|
||||
"Select files modified after this datetime.")
|
||||
|
||||
fs.StringVar(
|
||||
&FileModifiedBefore,
|
||||
&FileModifiedBeforeFV,
|
||||
FileModifiedBeforeFN, "",
|
||||
"Select files modified before this datetime.")
|
||||
}
|
||||
@ -119,7 +119,7 @@ func IncludeOneDriveRestoreDataSelectors(opts OneDriveOpts) *selectors.OneDriveR
|
||||
|
||||
sel := selectors.NewOneDriveRestore(users)
|
||||
|
||||
lp, ln := len(opts.FolderPaths), len(opts.FileNames)
|
||||
lp, ln := len(opts.FolderPath), len(opts.FileName)
|
||||
|
||||
// only use the inclusion if either a path or item name
|
||||
// is specified
|
||||
@ -128,20 +128,20 @@ func IncludeOneDriveRestoreDataSelectors(opts OneDriveOpts) *selectors.OneDriveR
|
||||
return sel
|
||||
}
|
||||
|
||||
opts.FolderPaths = trimFolderSlash(opts.FolderPaths)
|
||||
opts.FolderPath = trimFolderSlash(opts.FolderPath)
|
||||
|
||||
if ln == 0 {
|
||||
opts.FileNames = selectors.Any()
|
||||
opts.FileName = selectors.Any()
|
||||
}
|
||||
|
||||
containsFolders, prefixFolders := splitFoldersIntoContainsAndPrefix(opts.FolderPaths)
|
||||
containsFolders, prefixFolders := splitFoldersIntoContainsAndPrefix(opts.FolderPath)
|
||||
|
||||
if len(containsFolders) > 0 {
|
||||
sel.Include(sel.Items(containsFolders, opts.FileNames))
|
||||
sel.Include(sel.Items(containsFolders, opts.FileName))
|
||||
}
|
||||
|
||||
if len(prefixFolders) > 0 {
|
||||
sel.Include(sel.Items(prefixFolders, opts.FileNames, selectors.PrefixMatch()))
|
||||
sel.Include(sel.Items(prefixFolders, opts.FileName, selectors.PrefixMatch()))
|
||||
}
|
||||
|
||||
return sel
|
||||
|
||||
@ -36,54 +36,54 @@ func (suite *OneDriveUtilsSuite) TestIncludeOneDriveRestoreDataSelectors() {
|
||||
{
|
||||
name: "no inputs",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: empty,
|
||||
FileNames: empty,
|
||||
FolderPaths: empty,
|
||||
Users: empty,
|
||||
FileName: empty,
|
||||
FolderPath: empty,
|
||||
},
|
||||
expectIncludeLen: 1,
|
||||
},
|
||||
{
|
||||
name: "single inputs",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: single,
|
||||
FileNames: single,
|
||||
FolderPaths: single,
|
||||
Users: single,
|
||||
FileName: single,
|
||||
FolderPath: single,
|
||||
},
|
||||
expectIncludeLen: 1,
|
||||
},
|
||||
{
|
||||
name: "multi inputs",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: multi,
|
||||
FileNames: multi,
|
||||
FolderPaths: multi,
|
||||
Users: multi,
|
||||
FileName: multi,
|
||||
FolderPath: multi,
|
||||
},
|
||||
expectIncludeLen: 1,
|
||||
},
|
||||
{
|
||||
name: "folder contains",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: empty,
|
||||
FileNames: empty,
|
||||
FolderPaths: containsOnly,
|
||||
Users: empty,
|
||||
FileName: empty,
|
||||
FolderPath: containsOnly,
|
||||
},
|
||||
expectIncludeLen: 1,
|
||||
},
|
||||
{
|
||||
name: "folder prefixes",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: empty,
|
||||
FileNames: empty,
|
||||
FolderPaths: prefixOnly,
|
||||
Users: empty,
|
||||
FileName: empty,
|
||||
FolderPath: prefixOnly,
|
||||
},
|
||||
expectIncludeLen: 1,
|
||||
},
|
||||
{
|
||||
name: "folder prefixes and contains",
|
||||
opts: utils.OneDriveOpts{
|
||||
Users: empty,
|
||||
FileNames: empty,
|
||||
FolderPaths: containsAndPrefix,
|
||||
Users: empty,
|
||||
FileName: empty,
|
||||
FolderPath: containsAndPrefix,
|
||||
},
|
||||
expectIncludeLen: 2,
|
||||
},
|
||||
|
||||
@ -45,16 +45,16 @@ type SharePointOpts struct {
|
||||
|
||||
func MakeSharePointOpts(cmd *cobra.Command) SharePointOpts {
|
||||
return SharePointOpts{
|
||||
SiteID: SiteID,
|
||||
WebURL: WebURL,
|
||||
SiteID: SiteIDFV,
|
||||
WebURL: WebURLFV,
|
||||
|
||||
Library: Library,
|
||||
FileName: FileName,
|
||||
FolderPath: FolderPath,
|
||||
FileCreatedAfter: FileCreatedAfter,
|
||||
FileCreatedBefore: FileCreatedBefore,
|
||||
FileModifiedAfter: FileModifiedAfter,
|
||||
FileModifiedBefore: FileModifiedBefore,
|
||||
Library: LibraryFV,
|
||||
FileName: FileNameFV,
|
||||
FolderPath: FolderPathFV,
|
||||
FileCreatedAfter: FileCreatedAfterFV,
|
||||
FileCreatedBefore: FileCreatedBeforeFV,
|
||||
FileModifiedAfter: FileModifiedAfterFV,
|
||||
FileModifiedBefore: FileModifiedBeforeFV,
|
||||
|
||||
ListFolder: ListFolder,
|
||||
ListItem: ListItem,
|
||||
@ -74,31 +74,31 @@ func AddSharePointDetailsAndRestoreFlags(cmd *cobra.Command) {
|
||||
// libraries
|
||||
|
||||
fs.StringVar(
|
||||
&Library,
|
||||
&LibraryFV,
|
||||
LibraryFN, "",
|
||||
"Select only this library; defaults to all libraries.")
|
||||
fs.StringSliceVar(
|
||||
&FolderPath,
|
||||
&FolderPathFV,
|
||||
FolderFN, nil,
|
||||
"Select by folder; defaults to root.")
|
||||
fs.StringSliceVar(
|
||||
&FileName,
|
||||
&FileNameFV,
|
||||
FileFN, nil,
|
||||
"Select by file name.")
|
||||
fs.StringVar(
|
||||
&FileCreatedAfter,
|
||||
&FileCreatedAfterFV,
|
||||
FileCreatedAfterFN, "",
|
||||
"Select files created after this datetime.")
|
||||
fs.StringVar(
|
||||
&FileCreatedBefore,
|
||||
&FileCreatedBeforeFV,
|
||||
FileCreatedBeforeFN, "",
|
||||
"Select files created before this datetime.")
|
||||
fs.StringVar(
|
||||
&FileModifiedAfter,
|
||||
&FileModifiedAfterFV,
|
||||
FileModifiedAfterFN, "",
|
||||
"Select files modified after this datetime.")
|
||||
fs.StringVar(
|
||||
&FileModifiedBefore,
|
||||
&FileModifiedBeforeFV,
|
||||
FileModifiedBeforeFN, "",
|
||||
"Select files modified before this datetime.")
|
||||
|
||||
|
||||
64
src/cli/utils/testdata/flags.go
vendored
64
src/cli/utils/testdata/flags.go
vendored
@ -2,45 +2,45 @@ package testdata
|
||||
|
||||
import "strings"
|
||||
|
||||
func FlgInpts(in []string) string { return strings.Join(in, ",") }
|
||||
func FlgInputs(in []string) string { return strings.Join(in, ",") }
|
||||
|
||||
var (
|
||||
BackupInpt = "backup-id"
|
||||
BackupInput = "backup-id"
|
||||
|
||||
UsersInpt = []string{"users1", "users2"}
|
||||
SiteIDInpt = []string{"siteID1", "siteID2"}
|
||||
WebURLInpt = []string{"webURL1", "webURL2"}
|
||||
UsersInput = []string{"users1", "users2"}
|
||||
SiteIDInput = []string{"siteID1", "siteID2"}
|
||||
WebURLInput = []string{"webURL1", "webURL2"}
|
||||
|
||||
ContactInpt = []string{"contact1", "contact2"}
|
||||
ContactFldInpt = []string{"contactFld1", "contactFld2"}
|
||||
ContactNameInpt = "contactName"
|
||||
ContactInput = []string{"contact1", "contact2"}
|
||||
ContactFldInput = []string{"contactFld1", "contactFld2"}
|
||||
ContactNameInput = "contactName"
|
||||
|
||||
EmailInpt = []string{"mail1", "mail2"}
|
||||
EmailFldInpt = []string{"mailFld1", "mailFld2"}
|
||||
EmailReceivedAfterInpt = "mailReceivedAfter"
|
||||
EmailReceivedBeforeInpt = "mailReceivedBefore"
|
||||
EmailSenderInpt = "mailSender"
|
||||
EmailSubjectInpt = "mailSubjet"
|
||||
EmailInput = []string{"mail1", "mail2"}
|
||||
EmailFldInput = []string{"mailFld1", "mailFld2"}
|
||||
EmailReceivedAfterInput = "mailReceivedAfter"
|
||||
EmailReceivedBeforeInput = "mailReceivedBefore"
|
||||
EmailSenderInput = "mailSender"
|
||||
EmailSubjectInput = "mailSubjet"
|
||||
|
||||
EventInpt = []string{"event1", "event2"}
|
||||
EventCalInpt = []string{"eventCal1", "eventCal2"}
|
||||
EventOrganizerInpt = "eventOrganizer"
|
||||
EventRecursInpt = "eventRecurs"
|
||||
EventStartsAfterInpt = "eventStartsAfter"
|
||||
EventStartsBeforeInpt = "eventStartsBefore"
|
||||
EventSubjectInpt = "eventSubject"
|
||||
EventInput = []string{"event1", "event2"}
|
||||
EventCalInput = []string{"eventCal1", "eventCal2"}
|
||||
EventOrganizerInput = "eventOrganizer"
|
||||
EventRecursInput = "eventRecurs"
|
||||
EventStartsAfterInput = "eventStartsAfter"
|
||||
EventStartsBeforeInput = "eventStartsBefore"
|
||||
EventSubjectInput = "eventSubject"
|
||||
|
||||
LibraryInpt = "library"
|
||||
FileNamesInpt = []string{"fileName1", "fileName2"}
|
||||
FolderPathsInpt = []string{"folderPath1", "folderPath2"}
|
||||
FileCreatedAfterInpt = "fileCreatedAfter"
|
||||
FileCreatedBeforeInpt = "fileCreatedBefore"
|
||||
FileModifiedAfterInpt = "fileModifiedAfter"
|
||||
FileModifiedBeforeInpt = "fileModifiedBefore"
|
||||
LibraryInput = "library"
|
||||
FileNameInput = []string{"fileName1", "fileName2"}
|
||||
FolderPathInput = []string{"folderPath1", "folderPath2"}
|
||||
FileCreatedAfterInput = "fileCreatedAfter"
|
||||
FileCreatedBeforeInput = "fileCreatedBefore"
|
||||
FileModifiedAfterInput = "fileModifiedAfter"
|
||||
FileModifiedBeforeInput = "fileModifiedBefore"
|
||||
|
||||
ListFolderInpt = []string{"listFolder1", "listFolder2"}
|
||||
ListItemInpt = []string{"listItem1", "listItem2"}
|
||||
ListFolderInput = []string{"listFolder1", "listFolder2"}
|
||||
ListItemInput = []string{"listItem1", "listItem2"}
|
||||
|
||||
PageFolderInpt = []string{"pageFolder1", "pageFolder2"}
|
||||
PageInpt = []string{"page1", "page2"}
|
||||
PageFolderInput = []string{"pageFolder1", "pageFolder2"}
|
||||
PageInput = []string{"page1", "page2"}
|
||||
)
|
||||
|
||||
16
src/cli/utils/testdata/opts.go
vendored
16
src/cli/utils/testdata/opts.go
vendored
@ -352,28 +352,28 @@ var (
|
||||
Name: "AllFiles",
|
||||
Expected: testdata.OneDriveItems,
|
||||
Opts: utils.OneDriveOpts{
|
||||
FolderPaths: selectors.Any(),
|
||||
FolderPath: selectors.Any(),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "FolderPrefixMatch",
|
||||
Expected: testdata.OneDriveItems,
|
||||
Opts: utils.OneDriveOpts{
|
||||
FolderPaths: []string{testdata.OneDriveFolderFolder},
|
||||
FolderPath: []string{testdata.OneDriveFolderFolder},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "FolderPrefixMatchTrailingSlash",
|
||||
Expected: testdata.OneDriveItems,
|
||||
Opts: utils.OneDriveOpts{
|
||||
FolderPaths: []string{testdata.OneDriveFolderFolder + "/"},
|
||||
FolderPath: []string{testdata.OneDriveFolderFolder + "/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "FolderPrefixMatchTrailingSlash",
|
||||
Expected: testdata.OneDriveItems,
|
||||
Opts: utils.OneDriveOpts{
|
||||
FolderPaths: []string{testdata.OneDriveFolderFolder + "/"},
|
||||
FolderPath: []string{testdata.OneDriveFolderFolder + "/"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -383,7 +383,7 @@ var (
|
||||
testdata.OneDriveItems[1],
|
||||
},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileNames: []string{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItems[0].ShortRef,
|
||||
testdata.OneDriveItems[1].ShortRef,
|
||||
},
|
||||
@ -393,7 +393,7 @@ var (
|
||||
Name: "SingleItem",
|
||||
Expected: []details.DetailsEntry{testdata.OneDriveItems[0]},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileNames: []string{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItems[0].OneDrive.ItemName,
|
||||
},
|
||||
},
|
||||
@ -405,7 +405,7 @@ var (
|
||||
testdata.OneDriveItems[1],
|
||||
},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileNames: []string{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItems[0].OneDrive.ItemName,
|
||||
testdata.OneDriveItems[1].OneDrive.ItemName,
|
||||
},
|
||||
@ -415,7 +415,7 @@ var (
|
||||
Name: "NoSelectRepoItemName",
|
||||
Expected: []details.DetailsEntry{},
|
||||
Opts: utils.OneDriveOpts{
|
||||
FileNames: []string{
|
||||
FileName: []string{
|
||||
testdata.OneDriveItemPath1.Item(),
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user