console_tool

package
v0.0.0-...-7edcfce Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand

func AddCommand[T CommandGroup](parent *flags.Command, ctxBuilder ContextBulder, group T, makeHandler HandlerBuilder[T])

func ReadPassword

func ReadPassword(message ...string) string

Types

type AppBuilder

type AppBuilder interface {
	NewApp(buildConfig *app_context.BuildConfig) app_context.Context
	InitApp(app app_context.Context, configFile string, args []string, configType ...string) error
	NewSetupApp(buildConfig *app_context.BuildConfig) app_context.Context
	InitSetupApp(app app_context.Context, configFile string, args []string, configType ...string) error
	HasSetupApp() bool
	Tenancy(ctx op_context.Context, id string) (multitenancy.Tenancy, error)
	PoolController() pool.PoolController
}

type CommandGroup

type CommandGroup interface {
	Name() string
	Description() string
	InvokeInTenancy() bool
}

type CommandGroupBase

type CommandGroupBase struct {
	GroupName        string
	GroupDescription string
}

func NewCommandGroup

func NewCommandGroup(groupName string, groupDescription string) *CommandGroupBase

func (*CommandGroupBase) Description

func (c *CommandGroupBase) Description() string

func (*CommandGroupBase) InvokeInTenancy

func (c *CommandGroupBase) InvokeInTenancy() bool

func (*CommandGroupBase) Name

func (c *CommandGroupBase) Name() string

type Commands

type Commands[T CommandGroup] struct {
	*CommandGroupBase
	Self          T
	ExtraHandlers []HandlerBuilder[T]
	InTenancy     bool
}

func (Commands[T]) AddCommand

func (c Commands[T]) AddCommand(parent *flags.Command, ctxBuilder ContextBulder, group T)

func (*Commands[T]) AddHandlers

func (c *Commands[T]) AddHandlers(handlers ...HandlerBuilder[T])

func (*Commands[T]) Construct

func (c *Commands[T]) Construct(self T, name string, description string)

func (*Commands[T]) Description

func (c *Commands[T]) Description() string

func (*Commands[T]) Handlers

func (c *Commands[T]) Handlers(ctxBuilder ContextBulder, parser *flags.Parser) *flags.Command

func (*Commands[T]) InvokeInTenancy

func (c *Commands[T]) InvokeInTenancy() bool

func (*Commands[T]) Name

func (c *Commands[T]) Name() string

func (*Commands[T]) SubHandlers

func (c *Commands[T]) SubHandlers(ctxBuilder ContextBulder, parent *flags.Command) *flags.Command

type ConsoleUtility

type ConsoleUtility struct {
	Parser *flags.Parser
	App    app_context.Context
	Opts   MainOptions
	Args   []string

	AppBuilder  AppBuilder
	BuildConfig *app_context.BuildConfig
}

func New

func New(buildConfig *app_context.BuildConfig, appBuilder ...AppBuilder) *ConsoleUtility

func (*ConsoleUtility) AddCommandGroup

func (c *ConsoleUtility) AddCommandGroup(handler func(ctxBuilder ContextBulder, parser *flags.Parser) *flags.Command) *flags.Command

func (*ConsoleUtility) AddCommandSubgroup

func (c *ConsoleUtility) AddCommandSubgroup(parent *flags.Command, handler func(ctxBuilder ContextBulder, parent *flags.Command) *flags.Command) *flags.Command

func (*ConsoleUtility) Close

func (c *ConsoleUtility) Close()

func (*ConsoleUtility) InitCommandContext

func (c *ConsoleUtility) InitCommandContext(group string, command string) multitenancy.TenancyContext

func (*ConsoleUtility) Parse

func (c *ConsoleUtility) Parse()

type ContextBulder

type ContextBulder = func(group string, command string) multitenancy.TenancyContext

type Dummy

type Dummy struct{}

type GroupByData

type GroupByData struct {
	GroupBy []string `long:"groupby" description:"Fields to group by, can be specified multiple times"`
}

type Handler

type Handler[T CommandGroup] interface {
	CtxBuilder() ContextBulder
	HandlerGroup() T
	Construct(ctxBuilder ContextBulder, group T)
	HandlerName() string
	HandlerDescription() string
	Data() interface{}
}

type HandlerBase

type HandlerBase[T CommandGroup] struct {
	HandlerBaseHolder[T]
}

func (*HandlerBase[T]) Construct

func (h *HandlerBase[T]) Construct(ctxBuilder ContextBulder, group T)

func (*HandlerBase[T]) Context

func (h *HandlerBase[T]) Context(opData interface{}) (multitenancy.TenancyContext, error)

func (*HandlerBase[T]) CtxBuilder

func (h *HandlerBase[T]) CtxBuilder() ContextBulder

func (*HandlerBase[T]) Data

func (h *HandlerBase[T]) Data() interface{}

func (*HandlerBase[T]) HandlerDescription

func (h *HandlerBase[T]) HandlerDescription() string

func (*HandlerBase[T]) HandlerGroup

func (h *HandlerBase[T]) HandlerGroup() T

func (*HandlerBase[T]) HandlerName

func (h *HandlerBase[T]) HandlerName() string

func (*HandlerBase[T]) Init

func (h *HandlerBase[T]) Init(name string, description string)

type HandlerBaseHolder

type HandlerBaseHolder[T CommandGroup] struct {
	CtxBuilder  ContextBulder `no-flag:"true"`
	Group       T             `no-flag:"true"`
	Name        string        `no-flag:"true"`
	Description string        `no-flag:"true"`
}

type HandlerBuilder

type HandlerBuilder[T CommandGroup] func() Handler[T]

type InitApp

type InitApp = func(app app_context.Context, configFile string, args []string, configType ...string) error

type MainOptions

type MainOptions struct {
	ConfigFile   string `short:"c" long:"config" description:"Configuration file"`
	ConfigFormat string `short:"f" long:"config-format" description:"Format of configuration file" default:"json"`
	NoInitDb     bool   `short:"w" long:"without-database" description:"Don't initialize database"`
	Setup        bool   `short:"s" long:"setup" description:"Use minimal application features for initial setup"`
	DbSection    string `short:"d" long:"database-section" description:"Database section in configuration file" default:"db"`
	Tenancy      string `` /* 137-byte string literal not displayed */
	Args         string `short:"a" long:"args" description:"Additional configuration arguments."`
}

type QueryData

type QueryData struct {
	Query string `long:"query" description:"Query to filter items in response"`
}

type QueryWithGroupBy

type QueryWithGroupBy struct {
	QueryData
	GroupByData
}

Jump to

Keyboard shortcuts

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