Files
耗子 e8f7811aba feat: 重构 CLI 命令并补全缺失功能
website create 未传网站类型导致必然失败,补全类型、代理地址、
数据库、备注等参数,并在进入 biz 层前统一走验证器校验。

新增命令:
- firewall status/on/off/list/port
- cert list/renew
- restore panel
- website cert/list,user create/delete
- backup list,app list,cron list/run/status
- database list-server

调整:
- 密码取值改为参数 > ACEPANEL_PASSWORD > 交互输入(不回显)
- 补 bind-domain/bind-ip/bind-ua 的 on 子命令
- 新增全局 --json,接入全部 list 命令
- port 支持 flag 写法,info 支持 -u 指定用户
- 位置参数命令补 ArgsUsage

修复:
- cutoff clear 清理远程日志时目录与上传路径不一致,导致远程切割
  日志从未被清理,ClearStorageExpired 改为接收目标目录
- restore 缺少 panel 分支,从 FixPanel 抽出 restorePanel 复用

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 19:30:11 +08:00

114 lines
2.8 KiB
Go

package command
import (
"context"
"github.com/leonelquinteros/gotext"
"github.com/urfave/cli/v3"
"github.com/acepanel/panel/v3/internal/service"
)
// EntranceCommand 访问入口管理命令组
func EntranceCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
return &cli.Command{
Name: "entrance",
Usage: t.Get("Operate AcePanel access entrance"),
Commands: []*cli.Command{
{
Name: "on",
Usage: t.Get("Enable access entrance"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.EntranceOn(ctx, cmd)
},
},
{
Name: "off",
Usage: t.Get("Disable access entrance"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.EntranceOff(ctx, cmd)
},
},
},
}
}
// BindDomainCommand 域名绑定管理命令组
func BindDomainCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
return &cli.Command{
Name: "bind-domain",
Usage: t.Get("Operate AcePanel domain binding"),
Commands: []*cli.Command{
{
Name: "on",
Usage: t.Get("Enable domain binding"),
ArgsUsage: t.Get("<domain> [domain...]"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindDomainOn(ctx, cmd)
},
},
{
Name: "off",
Usage: t.Get("Disable domain binding"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindDomainOff(ctx, cmd)
},
},
},
}
}
// BindIPCommand IP 绑定管理命令组
func BindIPCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
return &cli.Command{
Name: "bind-ip",
Usage: t.Get("Operate AcePanel IP binding"),
Commands: []*cli.Command{
{
Name: "on",
Usage: t.Get("Enable IP binding"),
ArgsUsage: t.Get("<ip> [ip...]"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindIPOn(ctx, cmd)
},
},
{
Name: "off",
Usage: t.Get("Disable IP binding"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindIPOff(ctx, cmd)
},
},
},
}
}
// BindUACommand UA 绑定管理命令组
func BindUACommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
return &cli.Command{
Name: "bind-ua",
Usage: t.Get("Operate AcePanel UA binding"),
Commands: []*cli.Command{
{
Name: "on",
Usage: t.Get("Enable UA binding"),
ArgsUsage: t.Get("<user-agent> [user-agent...]"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindUAOn(ctx, cmd)
},
},
{
Name: "off",
Usage: t.Get("Disable UA binding"),
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.BindUAOff(ctx, cmd)
},
},
},
}
}