idecnode/cmd/fetcher/fetcher.go

36 lines
726 B
Go
Raw Permalink Normal View History

2024-10-20 03:39:07 +03:00
package fetcher
import (
"github.com/urfave/cli/v2"
"gitrepo.ru/neonxp/idecnode/pkg/config"
"gitrepo.ru/neonxp/idecnode/pkg/fetcher"
"gitrepo.ru/neonxp/idecnode/pkg/idec"
)
var FetcherCommand *cli.Command = &cli.Command{
Name: "fetch",
Description: "Fetch from other nodes",
Action: func(c *cli.Context) error {
configPath := c.String("config")
cfg, err := config.New(configPath)
if err != nil {
return err
}
idecApi, err := idec.New(cfg)
if err != nil {
return err
}
defer idecApi.Close()
return fetcher.New(idecApi, cfg).Run(c.Context)
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config",
DefaultText: "config path",
Value: "./etc/node.yaml",
},
},
}