test cobra

This commit is contained in:
wangchuxiao
2023-03-07 20:31:40 +08:00
parent c1746fb32e
commit 2c91185102
3 changed files with 54 additions and 7 deletions
+5 -4
View File
@@ -93,15 +93,16 @@ var clearCmd = &cobra.Command{
}
func main() {
cmd.RootCmd.PersistentFlags().StringP("userID", "u", "", "openIM userID")
cmd.RootCmd.PersistentFlags().StringP("groupID", "u", "", "openIM superGroupID")
rootCmd := cmd.NewMsgUtilsCmd()
rootCmd.Command.PersistentFlags().StringP("userID", "u", "", "openIM userID")
rootCmd.Command.PersistentFlags().StringP("groupID", "u", "", "openIM superGroupID")
seqCmd.Flags().BoolP("fixAll", "c", false, "openIM fix all seqs")
msgCmd.Flags().BoolP("clearAll", "c", false, "openIM clear all timeout msgs")
cmd.RootCmd.AddCommand(getCmd, fixCmd, clearCmd)
getCmd.AddCommand(seqCmd, msgCmd)
fixCmd.AddCommand(seqCmd)
clearCmd.AddCommand(msgCmd)
if err := cmd.RootCmd.Execute(); err != nil {
rootCmd.AddCommand(getCmd, fixCmd, clearCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}