Files
service-http/cmd/cobra.go
lwnmengjing 937a3cea60
Some checks failed
CI / build (push) Failing after 8m49s
init project
2025-11-13 16:53:08 +08:00

58 lines
1.3 KiB
Go
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cmd
import (
"errors"
"fmt"
"os"
"github.com/mss-boot-io/mss-boot/pkg"
"github.com/spf13/cobra"
"service-http/cmd/migrate"
"service-http/cmd/server"
)
/*
* @Author: lwnmengjing<lwnmengjing@qq.com>
* @Date: 2023/10/31 16:37:31
* @Last Modified by: lwnmengjing<lwnmengjing@qq.com>
* @Last Modified time: 2023/10/31 16:37:31
*/
var rootCmd = &cobra.Command{
Use: "service-http",
Short: "service-http",
SilenceUsage: true,
Long: `service-http is a background management system developed by the mss-boot framework`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
tip()
return errors.New(pkg.Red("requires at least one arg"))
}
return nil
},
PersistentPreRunE: func(*cobra.Command, []string) error { return nil },
Run: func(cmd *cobra.Command, args []string) {
tip()
},
}
func tip() {
usageStr := `欢迎使用 ` + pkg.Green(`service-http 0.0.1`) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令`
usageStr1 := `也可以参考 https://doc.mss-boot-io.top 的相关内容`
fmt.Printf("%s\n", usageStr)
fmt.Printf("%s\n", usageStr1)
}
func init() {
rootCmd.AddCommand(server.StartCmd)
rootCmd.AddCommand(migrate.StartCmd)
}
// Execute : apply commands
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(-1)
}
}