mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-29 02:10:58 +08:00
ea22c2f0a7
Replace the samber/do runtime container with explicit constructor dependencies and generated Wire graphs for ace and cli. Keep CLI application loading isolated and verify generated files in CI.
78 lines
1.7 KiB
Go
78 lines
1.7 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// DatabaseCommand 数据库管理命令组
|
|
func DatabaseCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
|
|
return &cli.Command{
|
|
Name: "database",
|
|
Usage: t.Get("Database management"),
|
|
Commands: []*cli.Command{
|
|
{
|
|
Name: "add-server",
|
|
Usage: t.Get("Add database server"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Usage: t.Get("Server type"),
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Server name"),
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "host",
|
|
Usage: t.Get("Server address"),
|
|
Required: true,
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "port",
|
|
Usage: t.Get("Server port"),
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "username",
|
|
Usage: t.Get("Server username"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "password",
|
|
Usage: t.Get("Server password"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "remark",
|
|
Usage: t.Get("Server remark"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.DatabaseAddServer(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "delete-server",
|
|
Usage: t.Get("Delete database server"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Server name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.DatabaseDeleteServer(ctx, cmd)
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|