1234567891011121314151617181920212223242526272829303132333435363738 |
- package pcmserver
- import (
- "dy-admin/internal/pcmserver/config"
- "dy-admin/internal/pcmserver/options"
- "dy-admin/pkg/app"
- "dy-admin/pkg/log"
- )
- const commandDesc = `pcm(phone cabinet manager) system command description`
- // NewApp creates an App object with default parameters.
- func NewApp(basename string) *app.App {
- opts := options.NewOptions()
- application := app.NewApp("pcm server",
- basename,
- app.WithOptions(opts),
- app.WithDescription(commandDesc),
- app.WithDefaultValidArgs(),
- app.WithRunFunc(run(opts)),
- )
- return application
- }
- func run(opts *options.Options) app.RunFunc {
- return func(basename string) error {
- log.Init(opts.LogOptions)
- defer log.Flush()
- cfg, err := config.CreateConfigFromOptions(opts)
- if err != nil {
- return err
- }
- return Run(cfg)
- }
- }
|