app.go 674 B

12345678910111213141516171819202122232425262728293031
  1. package iam
  2. import (
  3. "gogs.tyduyong.com/duyong/dy-admin/internal/iam/config"
  4. "gogs.tyduyong.com/duyong/dy-pkg/app"
  5. "gogs.tyduyong.com/duyong/dy-pkg/logs"
  6. )
  7. const commandDesc = `iam(identity and access management) system command description`
  8. func NewApp(basename string) *app.App {
  9. opts := config.NewConfig()
  10. application := app.NewApp("iam server",
  11. basename,
  12. app.WithOptions(opts),
  13. app.WithDescription(commandDesc),
  14. app.WithDefaultValidArgs(),
  15. app.WithRunFunc(run(opts)),
  16. )
  17. return application
  18. }
  19. func run(opts *config.Config) app.RunFunc {
  20. return func(basename string) error {
  21. logs.Init(opts.LogOptions)
  22. defer logs.Flush()
  23. return Run(opts)
  24. }
  25. }