cmds

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 53 Imported by: 0

Documentation

Overview

Package cmds provides command line tools.

Index

Constants

View Source
const HookNameCleanByHeightStorage = "clean_by_height_storage"

Variables

View Source
var (
	ContextValueDryRun                util.ContextKey = "dry_run"
	ContextValueHeight                util.ContextKey = "clean_storage_by_height_height"
	ContextValueCleanDatabaseByHeight util.ContextKey = "clean_database_by_height"
)
View Source
var (
	DefaultName        = "mitum"
	DefaultDescription = "mitum"
	MainOptions        = kong.HelpOptions{NoAppSummary: false, Compact: true, Summary: false, Tree: true}
)
View Source
var (
	ContextValueWhenBlockSaved util.ContextKey = "restore_when_block_saved"
	ContextValueWhenFinished   util.ContextKey = "restore_when_finished"
)
View Source
var BlockDownloadVars = kong.Vars{
	"block_datatypes": strings.Join(block.Blockdata, ","),
	"all_blockdata":   allBlockdata,
}
View Source
var ContextValueCleanDatabase util.ContextKey = "clean_database"
View Source
var DefaultConfigVars = kong.Vars{
	"default_config_default_format": "yaml",
}
View Source
var LogVars = kong.Vars{
	"log":        "",
	"log_level":  "info",
	"log_format": "terminal",
	"log_color":  "false",
}
View Source
var NodeConnectVars = kong.Vars{
	"node_connect_timeout":      "5s",
	"node_connect_tls_insecure": "false",
}
View Source
var PprofVars = kong.Vars{
	"enable_pprof":     "false",
	"mem_pprof_file":   "mitum-mem.pprof",
	"cpu_pprof_file":   "mitum-cpu.pprof",
	"trace_pprof_file": "mitum-trace.pprof",
}

Functions

func Context

func Context(args []string, flags interface{}, options ...kong.Option) (*kong.Context, error)

func DefaultProcesses

func DefaultProcesses() *pm.Processes

func LoadFromStdInput

func LoadFromStdInput() ([]byte, error)

func RunCPUPprof

func RunCPUPprof(s string) (func() error, error)

func RunMemPprof

func RunMemPprof(s string) (func() error, error)

func RunPprofs

func RunPprofs(flags *PprofFlags) (func() error, error)

func RunTracePprof

func RunTracePprof(s string) (func() error, error)

func SetupLoggingFromFlags

func SetupLoggingFromFlags(flags *LogFlags, defaultout io.Writer) (*logging.Logging, error)

Types

type BaseCommand

type BaseCommand struct {
	*logging.Logging
	*LogFlags
	*PprofFlags
	LogOutput io.Writer `kong:"-"`
	// contains filtered or unexported fields
}

func NewBaseCommand

func NewBaseCommand(name string) *BaseCommand

func (*BaseCommand) BSONEncoder

func (cmd *BaseCommand) BSONEncoder() *bsonenc.Encoder

func (*BaseCommand) Done

func (cmd *BaseCommand) Done()

func (*BaseCommand) Encoders

func (cmd *BaseCommand) Encoders() *encoder.Encoders

func (*BaseCommand) Initialize

func (cmd *BaseCommand) Initialize(flags interface{}, version util.Version) error

func (*BaseCommand) JSONEncoder

func (cmd *BaseCommand) JSONEncoder() *jsonenc.Encoder

func (*BaseCommand) LoadEncoders

func (cmd *BaseCommand) LoadEncoders(types []hint.Type, hinters []hint.Hinter) (*encoder.Encoders, error)

func (*BaseCommand) Version

func (cmd *BaseCommand) Version() util.Version

type BaseRunCommand

type BaseRunCommand struct {
	*BaseCommand
	Design FileLoad `arg:"" name:"node design file" help:"node design file"`
	// contains filtered or unexported fields
}

func NewBaseRunCommand

func NewBaseRunCommand(dryrun bool, name string) *BaseRunCommand

func (*BaseRunCommand) Processes

func (cmd *BaseRunCommand) Processes() *pm.Processes

func (*BaseRunCommand) SetProcesses

func (cmd *BaseRunCommand) SetProcesses(processes *pm.Processes) *BaseRunCommand

type BaseVerifyCommand

type BaseVerifyCommand struct {
	*BaseCommand
	NetworkID NetworkIDFlag `name:"network-id"`
	// contains filtered or unexported fields
}

func NewBaseVerifyCommand

func NewBaseVerifyCommand(name string, types []hint.Type, hinters []hint.Hinter) *BaseVerifyCommand

func (*BaseVerifyCommand) Initialize

func (cmd *BaseVerifyCommand) Initialize(flags interface{}, version util.Version) error

type BlockDownloadCommand

type BlockDownloadCommand struct {
	*BaseCommand
	DataType   string        `arg:"" name:"data type" help:"data type of block data, {${block_datatypes} ${all_blockdata}}" required:"true"` // revive:disable-line:line-length-limit
	Heights    []int64       `arg:"" name:"height" help:"heights of block" required:"true"`
	URL        *url.URL      `name:"node" help:"remote mitum url. default: ${node_url}" required:"true" default:"${node_url}"` // revive:disable-line:line-length-limit
	Timeout    time.Duration `name:"timeout" help:"timeout; default is 5 seconds"`
	TLSInscure bool          `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
	Save       string        `name:"save" help:"save block data under directory"`
	// contains filtered or unexported fields
}

func NewBlockDownloadCommand

func NewBlockDownloadCommand(types []hint.Type, hinters []hint.Hinter) BlockDownloadCommand

func (*BlockDownloadCommand) Run

func (cmd *BlockDownloadCommand) Run(version util.Version) error

type BlockdataVerifyCommand

type BlockdataVerifyCommand struct {
	*BaseVerifyCommand
	Path string `arg:"" name:"blockdata path"`
	// contains filtered or unexported fields
}

func NewBlockdataVerifyCommand

func NewBlockdataVerifyCommand(types []hint.Type, hinters []hint.Hinter) BlockdataVerifyCommand

func (*BlockdataVerifyCommand) Initialize

func (cmd *BlockdataVerifyCommand) Initialize(flags interface{}, version util.Version) error

func (*BlockdataVerifyCommand) Run

func (cmd *BlockdataVerifyCommand) Run(version util.Version) error

type CleanByHeightStorageCommand

type CleanByHeightStorageCommand struct {
	*BaseRunCommand
	Height int64 `arg:"" name:"height" help:"height of block" required:"true"`
	DryRun bool  `help:"dry-run" optional:"" default:"false"`
	// contains filtered or unexported fields
}

func NewCleanByHeightStorageCommand

func NewCleanByHeightStorageCommand() CleanByHeightStorageCommand

func (*CleanByHeightStorageCommand) Run

func (cmd *CleanByHeightStorageCommand) Run(version util.Version) error

type CleanStorageCommand

type CleanStorageCommand struct {
	*BaseRunCommand
	// contains filtered or unexported fields
}

func NewCleanStorageCommand

func NewCleanStorageCommand(dryrun bool) CleanStorageCommand

func (*CleanStorageCommand) Run

func (cmd *CleanStorageCommand) Run(version util.Version) error

type DatabaseVerifyCommand

type DatabaseVerifyCommand struct {
	*BaseVerifyCommand
	URI  string `arg:"" name:"database uri"`
	Path string `arg:"" name:"blockdata path"`
	// contains filtered or unexported fields
}

func NewDatabaseVerifyCommand

func NewDatabaseVerifyCommand(types []hint.Type, hinters []hint.Hinter) DatabaseVerifyCommand

func (*DatabaseVerifyCommand) Initialize

func (cmd *DatabaseVerifyCommand) Initialize(flags interface{}, version util.Version) error

func (*DatabaseVerifyCommand) Run

func (cmd *DatabaseVerifyCommand) Run(version util.Version) error

type DefaultConfigCommand

type DefaultConfigCommand struct {
	*BaseCommand
	Format string `help:"output format, {yaml}" default:"${default_config_default_format}"`
	// contains filtered or unexported fields
}

func NewDefaultConfigCommand

func NewDefaultConfigCommand() DefaultConfigCommand

func (*DefaultConfigCommand) Run

func (cmd *DefaultConfigCommand) Run(version util.Version) error

type DeployKeyKeyCommand

type DeployKeyKeyCommand struct {
	DeployKey string `arg:"" name:"deploy key"`
	// contains filtered or unexported fields
}

func NewDeployKeyKeyCommand

func NewDeployKeyKeyCommand() DeployKeyKeyCommand

func (DeployKeyKeyCommand) Initialize

func (cmd DeployKeyKeyCommand) Initialize(flags interface{}, version util.Version) error

func (*DeployKeyKeyCommand) Run

func (cmd *DeployKeyKeyCommand) Run(version util.Version) error

type DeployKeyKeysCommand

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

func NewDeployKeyKeysCommand

func NewDeployKeyKeysCommand() DeployKeyKeysCommand

func (DeployKeyKeysCommand) Initialize

func (cmd DeployKeyKeysCommand) Initialize(flags interface{}, version util.Version) error

func (*DeployKeyKeysCommand) Run

func (cmd *DeployKeyKeysCommand) Run(version util.Version) error

type DeployKeyNewCommand

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

func NewDeployKeyNewCommand

func NewDeployKeyNewCommand() DeployKeyNewCommand

func (DeployKeyNewCommand) Initialize

func (cmd DeployKeyNewCommand) Initialize(flags interface{}, version util.Version) error

func (*DeployKeyNewCommand) Run

func (cmd *DeployKeyNewCommand) Run(version util.Version) error

type DeployKeyRevokeCommand

type DeployKeyRevokeCommand struct {
	DeployKey string `arg:"" name:"deploy key"`
	// contains filtered or unexported fields
}

func NewDeployKeyRevokeCommand

func NewDeployKeyRevokeCommand() DeployKeyRevokeCommand

func (DeployKeyRevokeCommand) Initialize

func (cmd DeployKeyRevokeCommand) Initialize(flags interface{}, version util.Version) error

func (*DeployKeyRevokeCommand) Run

func (cmd *DeployKeyRevokeCommand) Run(version util.Version) error

type FileLoad

type FileLoad []byte

func (FileLoad) Bytes

func (v FileLoad) Bytes() []byte

func (FileLoad) MarshalText

func (v FileLoad) MarshalText() ([]byte, error)

func (FileLoad) String

func (v FileLoad) String() string

func (*FileLoad) UnmarshalText

func (v *FileLoad) UnmarshalText(b []byte) error

type InitCommand

type InitCommand struct {
	*BaseRunCommand
	Force bool `help:"clean the existing environment"`
}

func NewInitCommand

func NewInitCommand(dryrun bool) InitCommand

func (*InitCommand) Run

func (cmd *InitCommand) Run(version util.Version) error

type LogFlags

type LogFlags struct {
	LogColor  bool      `help:"show color log" default:"${log_color}"`                                                       // revive:disable-line:struct-tag,line-length-limit
	LogLevel  LogLevel  `help:"log level {trace debug error warn info crit} (default: ${log_level})" default:"${log_level}"` // revive:disable-line:struct-tag,line-length-limit
	LogFormat LogFormat `help:"log format {json terminal} (default: ${log_format})" default:"${log_format}"`
	LogFile   []string  `name:"log" help:"log file"`
}

type LogFormat

type LogFormat string

func (*LogFormat) UnmarshalText

func (lf *LogFormat) UnmarshalText(b []byte) error

type LogLevel

type LogLevel zerolog.Level

func (LogLevel) MarshalText

func (ll LogLevel) MarshalText() ([]byte, error)

func (*LogLevel) UnmarshalText

func (ll *LogLevel) UnmarshalText(b []byte) error

func (LogLevel) Zero

func (ll LogLevel) Zero() zerolog.Level

type NetworkIDFlag

type NetworkIDFlag []byte

func (NetworkIDFlag) NetworkID

func (v NetworkIDFlag) NetworkID() base.NetworkID

func (*NetworkIDFlag) UnmarshalText

func (v *NetworkIDFlag) UnmarshalText(b []byte) error

type NodeConnectFlags

type NodeConnectFlags struct {
	URL        *url.URL      `arg:"" name:"node url" help:"remote mitum url; default: ${node_url}" required:"true" default:"${node_url}"` // revive:disable-line:line-length-limit
	Timeout    time.Duration `name:"timeout" help:"timeout; default ${node_connect_timeout}" default:"${node_connect_timeout}"`           // revive:disable-line:line-length-limit
	TLSInscure bool          ``                                                                                                           // revive:disable-line:line-length-limit,struct-tag
	/* 134-byte string literal not displayed */
}

type NodeInfoCommand

type NodeInfoCommand struct {
	*BaseCommand
	URL        *url.URL      `arg:"" name:"node url" help:"remote mitum url" required:"true"`
	Timeout    time.Duration `name:"timeout" help:"timeout; default is 5 seconds"`
	TLSInscure bool          `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
}

func NewNodeInfoCommand

func NewNodeInfoCommand() NodeInfoCommand

func (*NodeInfoCommand) Run

func (cmd *NodeInfoCommand) Run(version util.Version) error

type PprofFlags

type PprofFlags struct {
	EnableProfiling bool   `name:"enable-pprof" help:"enable profiling (default:${enable_pprof})" default:"${enable_pprof}"`       // nolint
	MemProf         string `name:"pprof-mem" help:"memory prof file (default:${mem_pprof_file})" default:"${mem_pprof_file}"`      // nolint
	CPUProf         string `name:"pprof-cpu" help:"cpu prof file (default:${cpu_pprof_file})" default:"${cpu_pprof_file}"`         // nolint
	TraceProf       string `name:"pprof-trace" help:"trace prof file (default:${trace_pprof_file})" default:"${trace_pprof_file}"` // nolint
}

type QuicClientCommand

type QuicClientCommand struct {
	*BaseCommand
	URL        *url.URL      `arg:"" name:"node url" help:"remote mitum url" required:"true"`
	Timeout    time.Duration `name:"timeout" help:"timeout; default is 5 seconds"`
	TLSInscure bool          `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
	Method     string        `name:"method" help:"http method {GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATCH}; default is 'GET'"` // revive:disable-line:line-length-limit
	Headers    []string      `name:"header" help:"http header; <key>: <value>"`
	Body       FileLoad      `name:"body" help:"set http body" optional:""`
	JSON       bool          `name:"json" help:"json output format (default: false)" optional:"" default:"false"`
	// contains filtered or unexported fields
}

func NewQuicClientCommand

func NewQuicClientCommand() QuicClientCommand

func (*QuicClientCommand) Initialize

func (cmd *QuicClientCommand) Initialize(flags interface{}, version util.Version) error

func (*QuicClientCommand) Run

func (cmd *QuicClientCommand) Run(version util.Version) error

type RestoreCommand

type RestoreCommand struct {
	*BaseRunCommand
	Clean       bool   `help:"clean the existing data"`
	Concurrency uint64 `help:"how many blocks are handled at same time default: 10" default:"10"`
	Dryrun      bool   `help:"just check blockdata and database default: false" default:"false"`
	One         string `help:"restore one blockdata"`
	// contains filtered or unexported fields
}

func NewRestoreCommand

func NewRestoreCommand() RestoreCommand

func (*RestoreCommand) Run

func (cmd *RestoreCommand) Run(version util.Version) error

type RunCommand

type RunCommand struct {
	*BaseRunCommand
	Discovery      []*url.URL    `name:"discovery" help:"discovery node"`
	ExitAfter      time.Duration `name:"exit-after" help:"exit after the given duration"`
	NetworkLogFile []string      `name:"network-log" help:"network log file"`
	// contains filtered or unexported fields
}

func NewRunCommand

func NewRunCommand(dryrun bool) RunCommand

func (*RunCommand) AfterStartedHooks

func (cmd *RunCommand) AfterStartedHooks() *pm.Hooks

func (*RunCommand) Run

func (cmd *RunCommand) Run(version util.Version) error

type SetBlockdataMapsCommand

type SetBlockdataMapsCommand struct {
	*BaseCommand
	DeployKey string   `arg:"" name:"deploy key"`
	File      *os.File `arg:"" name:"maps file" help:"set blockdatamap file"`
	*NodeConnectFlags
	// contains filtered or unexported fields
}

func NewSetBlockdataMapsCommand

func NewSetBlockdataMapsCommand() SetBlockdataMapsCommand

func (*SetBlockdataMapsCommand) Run

func (cmd *SetBlockdataMapsCommand) Run(version util.Version) error

type StartHandoverCommand

type StartHandoverCommand struct {
	*BaseCommand
	Address    string        `arg:"" name:"node address" required:"true"`
	Key        string        `arg:"" name:"private key of node" required:"true"`
	NetworkID  string        `arg:"" name:"network-id" required:"true"`
	URL        *url.URL      `arg:"" name:"new node url" help:"new node url" required:"true"`
	Timeout    time.Duration `name:"timeout" help:"timeout; default is 5 seconds"`
	TLSInscure bool          `name:"tls-insecure" help:"allow inseucre TLS connection; default is false"`
	// contains filtered or unexported fields
}

func NewStartHandoverCommand

func NewStartHandoverCommand() StartHandoverCommand

func (*StartHandoverCommand) Run

func (cmd *StartHandoverCommand) Run(version util.Version) error

Jump to

Keyboard shortcuts

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