Warning in the help messages for pre-release hidden commands (#2307)
## Description A basic mechanism to show a warning for the help output of pre-release commands ## Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup ## Issue(s) ## Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
09821f2f0d
commit
3e106dbac8
@ -81,7 +81,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
|
|
||||||
switch cmd.Use {
|
switch cmd.Use {
|
||||||
case createCommand:
|
case createCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointCreateCmd(), utils.HideCommand())
|
c, fs = utils.AddCommand(cmd, sharePointCreateCmd(), utils.MarkPreReleaseCommand())
|
||||||
|
|
||||||
c.Use = c.Use + " " + sharePointServiceCommandCreateUseSuffix
|
c.Use = c.Use + " " + sharePointServiceCommandCreateUseSuffix
|
||||||
c.Example = sharePointServiceCommandCreateExamples
|
c.Example = sharePointServiceCommandCreateExamples
|
||||||
@ -101,14 +101,14 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
options.AddOperationFlags(c)
|
options.AddOperationFlags(c)
|
||||||
|
|
||||||
case listCommand:
|
case listCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointListCmd(), utils.HideCommand())
|
c, fs = utils.AddCommand(cmd, sharePointListCmd(), utils.MarkPreReleaseCommand())
|
||||||
|
|
||||||
fs.StringVar(&backupID,
|
fs.StringVar(&backupID,
|
||||||
utils.BackupFN, "",
|
utils.BackupFN, "",
|
||||||
"ID of the backup to retrieve.")
|
"ID of the backup to retrieve.")
|
||||||
|
|
||||||
case detailsCommand:
|
case detailsCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointDetailsCmd(), utils.HideCommand())
|
c, fs = utils.AddCommand(cmd, sharePointDetailsCmd(), utils.MarkPreReleaseCommand())
|
||||||
|
|
||||||
c.Use = c.Use + " " + sharePointServiceCommandDetailsUseSuffix
|
c.Use = c.Use + " " + sharePointServiceCommandDetailsUseSuffix
|
||||||
c.Example = sharePointServiceCommandDetailsExamples
|
c.Example = sharePointServiceCommandDetailsExamples
|
||||||
@ -157,7 +157,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
// "Select backup details for items created after this datetime.")
|
// "Select backup details for items created after this datetime.")
|
||||||
|
|
||||||
case deleteCommand:
|
case deleteCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointDeleteCmd(), utils.HideCommand())
|
c, fs = utils.AddCommand(cmd, sharePointDeleteCmd(), utils.MarkPreReleaseCommand())
|
||||||
|
|
||||||
c.Use = c.Use + " " + sharePointServiceCommandDeleteUseSuffix
|
c.Use = c.Use + " " + sharePointServiceCommandDeleteUseSuffix
|
||||||
c.Example = sharePointServiceCommandDeleteExamples
|
c.Example = sharePointServiceCommandDeleteExamples
|
||||||
|
|||||||
@ -33,7 +33,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
|||||||
|
|
||||||
switch cmd.Use {
|
switch cmd.Use {
|
||||||
case restoreCommand:
|
case restoreCommand:
|
||||||
c, fs = utils.AddCommand(cmd, sharePointRestoreCmd(), utils.HideCommand())
|
c, fs = utils.AddCommand(cmd, sharePointRestoreCmd(), utils.MarkPreReleaseCommand())
|
||||||
|
|
||||||
c.Use = c.Use + " " + sharePointServiceCommandUseSuffix
|
c.Use = c.Use + " " + sharePointServiceCommandUseSuffix
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,8 @@ func HasNoFlagsAndShownHelp(cmd *cobra.Command) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type cmdCfg struct {
|
type cmdCfg struct {
|
||||||
hidden bool
|
hidden bool
|
||||||
|
preRelese bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type cmdOpt func(*cmdCfg)
|
type cmdOpt func(*cmdCfg)
|
||||||
@ -76,6 +77,13 @@ func HideCommand() cmdOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MarkPreReleaseCommand() cmdOpt {
|
||||||
|
return func(cc *cmdCfg) {
|
||||||
|
cc.hidden = true
|
||||||
|
cc.preRelese = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AddCommand adds a clone of the subCommand to the parent,
|
// AddCommand adds a clone of the subCommand to the parent,
|
||||||
// and returns both the clone and its pflags.
|
// and returns both the clone and its pflags.
|
||||||
func AddCommand(parent, c *cobra.Command, opts ...cmdOpt) (*cobra.Command, *pflag.FlagSet) {
|
func AddCommand(parent, c *cobra.Command, opts ...cmdOpt) (*cobra.Command, *pflag.FlagSet) {
|
||||||
@ -85,6 +93,14 @@ func AddCommand(parent, c *cobra.Command, opts ...cmdOpt) (*cobra.Command, *pfla
|
|||||||
parent.AddCommand(c)
|
parent.AddCommand(c)
|
||||||
c.Hidden = cc.hidden
|
c.Hidden = cc.hidden
|
||||||
|
|
||||||
|
if cc.preRelese {
|
||||||
|
// There is a default deprecated message that always shows so we do some terminal magic to overwrite it
|
||||||
|
c.Deprecated = "\n\033[1F\033[K" +
|
||||||
|
"==================================================================================================\n" +
|
||||||
|
"\tWARNING!!! THIS IS A PRE-RELEASE COMMAND THAT MAY NOT FUNCTION PROPERLY, OR AT ALL\n" +
|
||||||
|
"==================================================================================================\n"
|
||||||
|
}
|
||||||
|
|
||||||
c.Flags().SortFlags = false
|
c.Flags().SortFlags = false
|
||||||
|
|
||||||
return c, c.Flags()
|
return c, c.Flags()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user