func Server(cfg *config.Config) *cli.Command {
	return &cli.Command{
		Name:  "server",
		Usage: "Start integrated server",
		Flags: ServerFlags(cfg),
		Action: func(c *cli.Context) error {
			logger := setupLogger(cfg)
			if c.IsSet("hcloud.config") {
				if err := readConfig(c.String("hcloud.config"), cfg); err != nil {
					level.Error(logger).Log(
						"msg", "Failed to read config",
						"err", err,
					)
					return err
				}
			}
			if cfg.Target.File == "" {
				level.Error(logger).Log(
					"msg", "Missing path for output.file",
				)
				return errors.New("missing path for output.file")
			}
			if c.IsSet("hcloud.token") {
				credentials := config.Credential{
					Project: "default",
					Token:   c.String("hcloud.token"),
				}
				cfg.Target.Credentials = append(
					cfg.Target.Credentials,
					credentials,
				)
				if credentials.Token == "" {
					level.Error(logger).Log(
						"msg", "Missing required hcloud.token",
					)
					return errors.New("missing required hcloud.token")
				}
			}
			if len(cfg.Target.Credentials) == 0 {
				level.Error(logger).Log(
					"msg", "Missing any credentials",
				)
				return errors.New("missing any credentials")
			}
			return action.Server(cfg, logger)
		},
	}
}
Server provides the sub-command to start the server.
package command
import (
	"errors"
	"github.com/go-kit/kit/log/level"
	"github.com/promhippie/prometheus-hcloud-sd/pkg/action"
	"github.com/promhippie/prometheus-hcloud-sd/pkg/config"
	"github.com/urfave/cli/v2"
)