func NewApplication()

in pkg/ecctl/app.go [38:65]


func NewApplication(c Config) (*App, error) {
	cfg, err := newAPIConfig(c)
	if err != nil {
		return nil, err
	}

	apiInstance, err := api.NewAPI(cfg)
	if err != nil {
		return nil, err
	}

	// Sets any extra message that is passed to the commentator
	GetOperationInstance().Set(c.Message)

	var fmter formatter.Formatter = formatter.New(c.OutputDevice, c.Output)
	if c.Format != "" {
		fmter = formatter.NewText(&formatter.TextConfig{
			Output:   c.OutputDevice,
			Override: c.Format,
		})
	}

	return &App{
		API:       apiInstance,
		Formatter: fmter,
		Config:    c,
	}, nil
}