You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

commandline.go 880 B

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. package cmdline
  2. import (
  3. "fmt"
  4. "os"
  5. "gitlink.org.cn/cloudream/common/pkgs/cmdtrie"
  6. "gitlink.org.cn/cloudream/storage/client/internal/services"
  7. )
  8. type CommandContext struct {
  9. Cmdline *Commandline
  10. }
  11. var commands cmdtrie.CommandTrie[CommandContext, error] = cmdtrie.NewCommandTrie[CommandContext, error]()
  12. type Commandline struct {
  13. Svc *services.Service
  14. }
  15. func NewCommandline(svc *services.Service) (*Commandline, error) {
  16. return &Commandline{
  17. Svc: svc,
  18. }, nil
  19. }
  20. func (c *Commandline) DispatchCommand(allArgs []string) {
  21. cmdCtx := CommandContext{
  22. Cmdline: c,
  23. }
  24. cmdErr, err := commands.Execute(cmdCtx, allArgs, cmdtrie.ExecuteOption{ReplaceEmptyArrayWithNil: true})
  25. if err != nil {
  26. fmt.Printf("execute command failed, err: %s", err.Error())
  27. os.Exit(1)
  28. }
  29. if cmdErr != nil {
  30. fmt.Printf("execute command failed, err: %s", cmdErr.Error())
  31. os.Exit(1)
  32. }
  33. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。