command

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MigrationStatus bool
	MigrationCmd    = &cobra.Command{
		Use:          "migrate",
		Short:        "Run database migrations",
		Example:      "herman migrate --direction=up --number=1",
		SilenceUsage: true,
		RunE: func(cmd *cobra.Command, args []string) error {
			if err := Migrate(direction); err != nil {
				return err
			}
			return nil
		},
	}
)

MigrationCmd 数据库迁移

View Source
var (
	IsMigrate      bool
	StartServerCmd = &cobra.Command{
		Use:          "server",
		Short:        "This is a herman service",
		SilenceUsage: true,
		Example:      "herman server --host=0.0.0.0 --port=8000",
		Run: func(cmd *cobra.Command, args []string) {
			servers.NewServer(host, port)
		},
	}
)

StartServerCmd 服务启动

View Source
var (
	GenerateJwtCmd = &cobra.Command{
		Use:          "jwt:secret",
		Short:        "Generate a secret for JWT",
		Example:      "jwt:secret",
		SilenceUsage: true,
		RunE: func(cmd *cobra.Command, args []string) error {

			key := make([]byte, 32)
			if _, err := rand.Read(key); err != nil {
				return err
			}

			encodedKey := base64.StdEncoding.EncodeToString(key)

			fmt.Println("Jwt secret:", color.GreenString(encodedKey))
			return nil
		},
	}
)

GenerateJwtCmd 随机生成JWT令牌

View Source
var (
	HermanVersionCmd = &cobra.Command{
		Use:          "version",
		Short:        "Get herman version",
		Example:      "herman version",
		SilenceUsage: true,
		RunE: func(cmd *cobra.Command, args []string) error {
			fmt.Printf(`Herman version: %v`, color.GreenString(app.Version))
			return nil
		},
	}
)

HermanVersionCmd 获取herman版本号

Functions

func Migrate

func Migrate(direction string) error

Migrate 数据库迁移 @return error 错误信息

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL