app.go 698 B

12345678910111213141516171819202122232425262728293031323334
  1. package pcmserver
  2. import (
  3. "dy-admin/internal/pcmserver/options"
  4. "dy-admin/pkg/app"
  5. "dy-admin/pkg/log"
  6. "fmt"
  7. )
  8. const commandDesc = `pcm(phone cabinet manager) system command description`
  9. // NewApp creates an App object with default parameters.
  10. func NewApp(basename string) *app.App {
  11. opts := options.NewOptions()
  12. application := app.NewApp("pcm server",
  13. basename,
  14. app.WithOptions(opts),
  15. app.WithDescription(commandDesc),
  16. app.WithDefaultValidArgs(),
  17. app.WithRunFunc(run(opts)),
  18. )
  19. return application
  20. }
  21. func run(opts *options.Options) app.RunFunc {
  22. return func(basename string) error {
  23. log.Init(opts.LogOptions)
  24. defer log.Flush()
  25. fmt.Println("run...")
  26. return nil
  27. }
  28. }