Files
go-admin/cmd/cobra.go
T
2020-06-28 22:48:32 +08:00

42 lines
870 B
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"
"github.com/spf13/cobra"
"go-admin/cmd/api"
"go-admin/cmd/migrate"
"os"
)
var rootCmd = &cobra.Command{
Use: "go-admin",
Short: "-v",
SilenceUsage: true,
DisableAutoGenTag: true,
Long: `go-admin`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("requires at least one arg")
}
return nil
},
PersistentPreRunE: func(*cobra.Command, []string) error { return nil },
Run: func(cmd *cobra.Command, args []string) {
usageStr := `go-admin 1.0.0 欢迎使用,可以使用 -h 查看命令`
fmt.Printf("%s\n", usageStr)
},
}
func init() {
rootCmd.AddCommand(api.StartCmd)
rootCmd.AddCommand(migrate.StartCmd)
}
//Execute : apply commands
func Execute() {
if err := rootCmd.Execute(); err != nil {
os.Exit(-1)
}
}