cmd

package
v0.1.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migrate = &cobra.Command{
	RunE: func(cmd *cobra.Command, args []string) error {
		conn, err := gorm.Open(postgres.Open(cfg.DSN()), &gorm.Config{
			NamingStrategy: schema.NamingStrategy{
				TablePrefix: cfg.Prefix(),
			},
		})
		if err != nil {
			return err
		}

		db := db.NewDB(conn)
		err = db.RunMigrations()
		if err != nil {
			return err
		}

		return nil
	},
}
View Source
var Root = &cobra.Command{
	RunE: func(cmd *cobra.Command, args []string) error {
		srv := NewWebSrv(cfg)

		s, _ := server.WithContext(cmd.Context())
		s.Listen(srv, false)

		return s.Wait()
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Flags *Flags
}

Config ...

func New

func New() *Config

New ...

func (*Config) Cwd

func (c *Config) Cwd() (string, error)

Cwd returns the current working directory.

func (*Config) DSN added in v0.1.15

func (c *Config) DSN() string

DSN for PostgreSQL.

func (*Config) Prefix added in v0.1.26

func (c *Config) Prefix() string

Prefix ...

type DB

type DB struct {
	Addr     string
	Database string
	Password string
	Port     int
	Username string
	Prefix   string
}

DB ...

type Flags

type Flags struct {
	Addr string
	DB   *DB
}

Flags contains the command line flags.

func NewFlags

func NewFlags() *Flags

NewFlags ...

type WebSrv

type WebSrv struct {
	// contains filtered or unexported fields
}

WebSrv is the server that implements the Noop interface.

func NewWebSrv

func NewWebSrv(cfg *Config) *WebSrv

NewWebSrv returns a new instance of NoopSrv.

func (*WebSrv) Start

func (s *WebSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.RunFunc) func() error

Start starts the server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL