diff --git a/src/cli/backup/exchange.go b/src/cli/backup/exchange.go index 72d6ab857..b9f399c7e 100644 --- a/src/cli/backup/exchange.go +++ b/src/cli/backup/exchange.go @@ -3,7 +3,6 @@ package backup import ( "github.com/alcionai/clues" "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" . "github.com/alcionai/corso/src/cli/print" @@ -62,15 +61,11 @@ corso backup details exchange --backup 1234abcd-12ab-cd34-56de-1234abcd \ // called by backup.go to map subcommands to provider-specific handling. func addExchangeCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case createCommand: - c, fs = utils.AddCommand(cmd, exchangeCreateCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, exchangeCreateCmd()) c.Use = c.Use + " " + exchangeServiceCommandCreateUseSuffix c.Example = exchangeServiceCommandCreateExamples @@ -87,15 +82,13 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command { flags.AddDisableSlidingWindowLimiterFlag(c) case listCommand: - c, fs = utils.AddCommand(cmd, exchangeListCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, exchangeListCmd()) flags.AddBackupIDFlag(c, false) flags.AddAllBackupListFlags(c) case detailsCommand: - c, fs = utils.AddCommand(cmd, exchangeDetailsCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, exchangeDetailsCmd()) c.Use = c.Use + " " + exchangeServiceCommandDetailsUseSuffix c.Example = exchangeServiceCommandDetailsExamples @@ -108,8 +101,7 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command { flags.AddExchangeDetailsAndRestoreFlags(c, false) case deleteCommand: - c, fs = utils.AddCommand(cmd, exchangeDeleteCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, exchangeDeleteCmd()) c.Use = c.Use + " " + exchangeServiceCommandDeleteUseSuffix c.Example = exchangeServiceCommandDeleteExamples diff --git a/src/cli/backup/groups.go b/src/cli/backup/groups.go index f2ad9bec8..2a8ab3024 100644 --- a/src/cli/backup/groups.go +++ b/src/cli/backup/groups.go @@ -6,7 +6,6 @@ import ( "github.com/alcionai/clues" "github.com/spf13/cobra" - "github.com/spf13/pflag" "golang.org/x/exp/slices" "github.com/alcionai/corso/src/cli/flags" @@ -56,15 +55,11 @@ corso backup details groups --backup 1234abcd-12ab-cd34-56de-1234abcd \ // called by backup.go to map subcommands to provider-specific handling. func addGroupsCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case createCommand: - c, fs = utils.AddCommand(cmd, groupsCreateCmd(), utils.MarkPreviewCommand()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, groupsCreateCmd(), utils.MarkPreviewCommand()) c.Use = c.Use + " " + groupsServiceCommandCreateUseSuffix c.Example = groupsServiceCommandCreateExamples @@ -78,15 +73,13 @@ func addGroupsCommands(cmd *cobra.Command) *cobra.Command { flags.AddDisableLazyItemReader(c) case listCommand: - c, fs = utils.AddCommand(cmd, groupsListCmd(), utils.MarkPreviewCommand()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, groupsListCmd(), utils.MarkPreviewCommand()) flags.AddBackupIDFlag(c, false) flags.AddAllBackupListFlags(c) case detailsCommand: - c, fs = utils.AddCommand(cmd, groupsDetailsCmd(), utils.MarkPreviewCommand()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, groupsDetailsCmd(), utils.MarkPreviewCommand()) c.Use = c.Use + " " + groupsServiceCommandDetailsUseSuffix c.Example = groupsServiceCommandDetailsExamples @@ -100,8 +93,7 @@ func addGroupsCommands(cmd *cobra.Command) *cobra.Command { flags.AddSharePointDetailsAndRestoreFlags(c) case deleteCommand: - c, fs = utils.AddCommand(cmd, groupsDeleteCmd(), utils.MarkPreviewCommand()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, groupsDeleteCmd(), utils.MarkPreviewCommand()) c.Use = c.Use + " " + groupsServiceCommandDeleteUseSuffix c.Example = groupsServiceCommandDeleteExamples diff --git a/src/cli/backup/onedrive.go b/src/cli/backup/onedrive.go index 1f14a8213..86ac19394 100644 --- a/src/cli/backup/onedrive.go +++ b/src/cli/backup/onedrive.go @@ -60,7 +60,6 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { switch cmd.Use { case createCommand: c, fs = utils.AddCommand(cmd, oneDriveCreateCmd()) - fs.SortFlags = false c.Use = c.Use + " " + oneDriveServiceCommandCreateUseSuffix c.Example = oneDriveServiceCommandCreateExamples @@ -75,15 +74,13 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { cobra.CheckErr(fs.MarkHidden(flags.UseDeltaTreeFN)) case listCommand: - c, fs = utils.AddCommand(cmd, oneDriveListCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, oneDriveListCmd()) flags.AddBackupIDFlag(c, false) flags.AddAllBackupListFlags(c) case detailsCommand: - c, fs = utils.AddCommand(cmd, oneDriveDetailsCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, oneDriveDetailsCmd()) c.Use = c.Use + " " + oneDriveServiceCommandDetailsUseSuffix c.Example = oneDriveServiceCommandDetailsExamples @@ -93,8 +90,7 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { flags.AddOneDriveDetailsAndRestoreFlags(c) case deleteCommand: - c, fs = utils.AddCommand(cmd, oneDriveDeleteCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, oneDriveDeleteCmd()) c.Use = c.Use + " " + oneDriveServiceCommandDeleteUseSuffix c.Example = oneDriveServiceCommandDeleteExamples diff --git a/src/cli/backup/sharepoint.go b/src/cli/backup/sharepoint.go index 4ae2d1a68..1ce30eca6 100644 --- a/src/cli/backup/sharepoint.go +++ b/src/cli/backup/sharepoint.go @@ -5,7 +5,6 @@ import ( "github.com/alcionai/clues" "github.com/spf13/cobra" - "github.com/spf13/pflag" "golang.org/x/exp/slices" "github.com/alcionai/corso/src/cli/flags" @@ -63,15 +62,11 @@ corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \ // called by backup.go to map subcommands to provider-specific handling. func addSharePointCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case createCommand: - c, fs = utils.AddCommand(cmd, sharePointCreateCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, sharePointCreateCmd()) c.Use = c.Use + " " + sharePointServiceCommandCreateUseSuffix c.Example = sharePointServiceCommandCreateExamples @@ -82,15 +77,13 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { flags.AddGenericBackupFlags(c) case listCommand: - c, fs = utils.AddCommand(cmd, sharePointListCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, sharePointListCmd()) flags.AddBackupIDFlag(c, false) flags.AddAllBackupListFlags(c) case detailsCommand: - c, fs = utils.AddCommand(cmd, sharePointDetailsCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, sharePointDetailsCmd()) c.Use = c.Use + " " + sharePointServiceCommandDetailsUseSuffix c.Example = sharePointServiceCommandDetailsExamples @@ -100,8 +93,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { flags.AddSharePointDetailsAndRestoreFlags(c) case deleteCommand: - c, fs = utils.AddCommand(cmd, sharePointDeleteCmd()) - fs.SortFlags = false + c, _ = utils.AddCommand(cmd, sharePointDeleteCmd()) c.Use = c.Use + " " + sharePointServiceCommandDeleteUseSuffix c.Example = sharePointServiceCommandDeleteExamples diff --git a/src/cli/debug/exchange.go b/src/cli/debug/exchange.go index adc6c19df..3bf9c457f 100644 --- a/src/cli/debug/exchange.go +++ b/src/cli/debug/exchange.go @@ -2,7 +2,6 @@ package debug import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,13 @@ import ( // called by debug.go to map subcommands to provider-specific handling. func addExchangeCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case metadataFilesCommand: - c, fs = utils.AddCommand(cmd, exchangeMetadataFilesCmd(), utils.MarkDebugCommand()) - + c, _ = utils.AddCommand(cmd, exchangeMetadataFilesCmd(), utils.MarkDebugCommand()) c.Use = c.Use + " " + exchangeServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) } diff --git a/src/cli/debug/groups.go b/src/cli/debug/groups.go index 3335e9e0c..f81d9dba6 100644 --- a/src/cli/debug/groups.go +++ b/src/cli/debug/groups.go @@ -2,7 +2,6 @@ package debug import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,14 @@ import ( // called by debug.go to map subcommands to provider-specific handling. func addGroupsCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case metadataFilesCommand: - c, fs = utils.AddCommand(cmd, groupsMetadataFilesCmd(), utils.MarkDebugCommand()) + c, _ = utils.AddCommand(cmd, groupsMetadataFilesCmd(), utils.MarkDebugCommand()) c.Use = c.Use + " " + groupsServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) } diff --git a/src/cli/debug/onedrive.go b/src/cli/debug/onedrive.go index 902a1f748..10254e0e4 100644 --- a/src/cli/debug/onedrive.go +++ b/src/cli/debug/onedrive.go @@ -2,7 +2,6 @@ package debug import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,13 @@ import ( // called by debug.go to map subcommands to provider-specific handling. func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case metadataFilesCommand: - c, fs = utils.AddCommand(cmd, oneDriveMetadataFilesCmd(), utils.MarkDebugCommand()) - + c, _ = utils.AddCommand(cmd, oneDriveMetadataFilesCmd(), utils.MarkDebugCommand()) c.Use = c.Use + " " + oneDriveServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) } diff --git a/src/cli/debug/sharepoint.go b/src/cli/debug/sharepoint.go index dd6a18383..7380be60f 100644 --- a/src/cli/debug/sharepoint.go +++ b/src/cli/debug/sharepoint.go @@ -2,7 +2,6 @@ package debug import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,13 @@ import ( // called by debug.go to map subcommands to provider-specific handling. func addSharePointCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case metadataFilesCommand: - c, fs = utils.AddCommand(cmd, sharePointMetadataFilesCmd(), utils.MarkDebugCommand()) - + c, _ = utils.AddCommand(cmd, sharePointMetadataFilesCmd(), utils.MarkDebugCommand()) c.Use = c.Use + " " + sharePointServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) } diff --git a/src/cli/export/exchange.go b/src/cli/export/exchange.go index 90e2a9852..9c42d2276 100644 --- a/src/cli/export/exchange.go +++ b/src/cli/export/exchange.go @@ -3,7 +3,6 @@ package export import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,14 @@ import ( // called by export.go to map subcommands to provider-specific handling. func addExchangeCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case exportCommand: - c, fs = utils.AddCommand(cmd, exchangeExportCmd()) + c, _ = utils.AddCommand(cmd, exchangeExportCmd()) c.Use = c.Use + " " + exchangeServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddExchangeDetailsAndRestoreFlags(c, true) flags.AddExportConfigFlags(c) diff --git a/src/cli/export/groups.go b/src/cli/export/groups.go index 355987b8d..8d5a9d51c 100644 --- a/src/cli/export/groups.go +++ b/src/cli/export/groups.go @@ -3,7 +3,6 @@ package export import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -13,21 +12,14 @@ import ( // called by export.go to map subcommands to provider-specific handling. func addGroupsCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case exportCommand: - c, fs = utils.AddCommand(cmd, groupsExportCmd(), utils.MarkPreviewCommand()) + c, _ = utils.AddCommand(cmd, groupsExportCmd(), utils.MarkPreviewCommand()) c.Use = c.Use + " " + groupsServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddSiteFlag(c, false) flags.AddSiteIDFlag(c, false) diff --git a/src/cli/export/onedrive.go b/src/cli/export/onedrive.go index c6fb54165..ecd7e876a 100644 --- a/src/cli/export/onedrive.go +++ b/src/cli/export/onedrive.go @@ -3,7 +3,6 @@ package export import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,14 @@ import ( // called by export.go to map subcommands to provider-specific handling. func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case exportCommand: - c, fs = utils.AddCommand(cmd, oneDriveExportCmd()) + c, _ = utils.AddCommand(cmd, oneDriveExportCmd()) c.Use = c.Use + " " + oneDriveServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddOneDriveDetailsAndRestoreFlags(c) flags.AddExportConfigFlags(c) diff --git a/src/cli/export/sharepoint.go b/src/cli/export/sharepoint.go index 08cc0dbe0..e29e80295 100644 --- a/src/cli/export/sharepoint.go +++ b/src/cli/export/sharepoint.go @@ -3,7 +3,6 @@ package export import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -12,21 +11,14 @@ import ( // called by export.go to map subcommands to provider-specific handling. func addSharePointCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case exportCommand: - c, fs = utils.AddCommand(cmd, sharePointExportCmd()) + c, _ = utils.AddCommand(cmd, sharePointExportCmd()) c.Use = c.Use + " " + sharePointServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddSharePointDetailsAndRestoreFlags(c) flags.AddExportConfigFlags(c) diff --git a/src/cli/restore/exchange.go b/src/cli/restore/exchange.go index 77793a31e..13408bf44 100644 --- a/src/cli/restore/exchange.go +++ b/src/cli/restore/exchange.go @@ -2,7 +2,6 @@ package restore import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -10,22 +9,14 @@ import ( // called by restore.go to map subcommands to provider-specific handling. func addExchangeCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case restoreCommand: - c, fs = utils.AddCommand(cmd, exchangeRestoreCmd()) + c, _ = utils.AddCommand(cmd, exchangeRestoreCmd()) c.Use = c.Use + " " + exchangeServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - // general flags - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddExchangeDetailsAndRestoreFlags(c, false) flags.AddRestoreConfigFlags(c, true) diff --git a/src/cli/restore/groups.go b/src/cli/restore/groups.go index 08d6a8949..310a99df9 100644 --- a/src/cli/restore/groups.go +++ b/src/cli/restore/groups.go @@ -2,7 +2,6 @@ package restore import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -12,21 +11,14 @@ import ( // called by restore.go to map subcommands to provider-specific handling. func addGroupsCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case restoreCommand: - c, fs = utils.AddCommand(cmd, groupsRestoreCmd(), utils.MarkPreviewCommand()) + c, _ = utils.AddCommand(cmd, groupsRestoreCmd(), utils.MarkPreviewCommand()) c.Use = c.Use + " " + groupsServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddSiteFlag(c, false) flags.AddSiteIDFlag(c, false) diff --git a/src/cli/restore/onedrive.go b/src/cli/restore/onedrive.go index 27b2642c8..0ab83bd35 100644 --- a/src/cli/restore/onedrive.go +++ b/src/cli/restore/onedrive.go @@ -2,7 +2,6 @@ package restore import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -11,21 +10,14 @@ import ( // called by restore.go to map subcommands to provider-specific handling. func addOneDriveCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case restoreCommand: - c, fs = utils.AddCommand(cmd, oneDriveRestoreCmd()) + c, _ = utils.AddCommand(cmd, oneDriveRestoreCmd()) c.Use = c.Use + " " + oneDriveServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --user) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddOneDriveDetailsAndRestoreFlags(c) flags.AddNoPermissionsFlag(c) diff --git a/src/cli/restore/sharepoint.go b/src/cli/restore/sharepoint.go index 3fc3ed0e5..5c0c1efd3 100644 --- a/src/cli/restore/sharepoint.go +++ b/src/cli/restore/sharepoint.go @@ -2,7 +2,6 @@ package restore import ( "github.com/spf13/cobra" - "github.com/spf13/pflag" "github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/utils" @@ -12,21 +11,14 @@ import ( // called by restore.go to map subcommands to provider-specific handling. func addSharePointCommands(cmd *cobra.Command) *cobra.Command { - var ( - c *cobra.Command - fs *pflag.FlagSet - ) + var c *cobra.Command switch cmd.Use { case restoreCommand: - c, fs = utils.AddCommand(cmd, sharePointRestoreCmd()) + c, _ = utils.AddCommand(cmd, sharePointRestoreCmd()) c.Use = c.Use + " " + sharePointServiceCommandUseSuffix - // Flags addition ordering should follow the order we want them to appear in help and docs: - // More generic (ex: --site) and more frequently used flags take precedence. - fs.SortFlags = false - flags.AddBackupIDFlag(c, true) flags.AddSharePointDetailsAndRestoreFlags(c) flags.AddNoPermissionsFlag(c)