func (a *App) Init(dir string) error {
	if a.conf == nil {
		a.conf = &cli.Config{}
	}
	a.initflags()
	return errs.Pair(a.SetConfig(dir), a.InitDB())
}
Init wil setup the app.
package cmd
import (
	"fmt"
	"io"
	"log"
	"os"
	"os/exec"
	fp "path/filepath"
	"github.com/harrybrwn/apizza/cmd/cli"
	"github.com/harrybrwn/apizza/cmd/client"
	"github.com/harrybrwn/apizza/cmd/internal"
	"github.com/harrybrwn/apizza/cmd/internal/data"
	"github.com/harrybrwn/apizza/cmd/internal/obj"
	"github.com/harrybrwn/apizza/cmd/opts"
	"github.com/harrybrwn/apizza/dawg"
	"github.com/harrybrwn/apizza/pkg/cache"
	"github.com/harrybrwn/apizza/pkg/config"
	"github.com/harrybrwn/apizza/pkg/errs"
	"github.com/spf13/cobra"
)
type App struct {
	cli.CliCommand      
	client.StoreFinder  
	db   *cache.DataBase
	conf *cli.Config
	addr *obj.Address
	logf *os.File
	gOpts opts.CliFlags
	opts opts.ApizzaFlags
}
func NewApp(out io.Writer) *App {
	app := &App{
		db:    nil,
		conf:  &cli.Config{},
		gOpts: opts.CliFlags{},
		opts:  opts.ApizzaFlags{},
	}
	app.CliCommand = cli.NewCommand("apizza", "Dominos pizza from the command line.", app.Run)
	app.StoreFinder = client.NewStoreGetterFunc(app.getService, app.Address)
	cmd := app.Cmd()
	cmd.PersistentPreRunE = app.prerun
	cmd.PostRunE = app.postrun
	app.SetOutput(out)
	return app
}
func CreateApp(db *cache.DataBase, conf *cli.Config, out io.Writer) *App {
	app := NewApp(out)
	app.db = db
	app.conf = conf
	return app
}