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 1.1 kB

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

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