cli

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Functions

func ArgSplit

func ArgSplit(str string) (result []string)

func BuntdbCompleter

func BuntdbCompleter(d prompt.Document) []prompt.Suggest

func BuntdbExecutor

func BuntdbExecutor(s string)

Types

type CommitGrammar added in v0.0.2

type CommitGrammar struct{}

func (*CommitGrammar) Run added in v0.0.2

func (c *CommitGrammar) Run(ctx *kong.Context) error

type DBSizeGrammar added in v0.0.8

type DBSizeGrammar struct {
}

func (*DBSizeGrammar) Run added in v0.0.8

func (h *DBSizeGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) (err error)

type DelGrammar

type DelGrammar struct {
	Key string `arg:"" help:"the key to delete"`
}

func (*DelGrammar) Run

func (d *DelGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type DropGrammar added in v0.0.3

type DropGrammar struct {
	Index DropIndexGrammar `cmd:"" help:"drop the index with the given name"`
}

type DropIndexGrammar added in v0.0.3

type DropIndexGrammar struct {
	Name string `arg:"" help:"the index name to drop"`
}

func (*DropIndexGrammar) Run added in v0.0.3

func (s *DropIndexGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type GetGrammar

type GetGrammar struct {
	Key          string `arg:"" help:"the key to get"`
	IgnoreExpire bool   `help:"ignore expire"`
}

func (*GetGrammar) Run

func (g *GetGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type Grammar

type Grammar struct {
	Get      GetGrammar      `cmd:"" help:"get a value from key, return the value if key exists, or <nil> if non-exists."`
	Set      SetGrammar      `cmd:"" help:"set a key-value [ttl], return the old value, or <nil> if old value doesn't exist."`
	Del      DelGrammar      `cmd:"" help:"delete a key, return 1 if success, or 0 if key doesn't exist."`
	Show     ShowGrammar     `cmd:"" help:"show index or db."`
	Keys     KeysGrammar     `cmd:"" help:"iterate over the key match the pattern, support '?' and '*'."`
	Use      UseGrammar      `cmd:"" help:"switch to other db."`
	TTL      TTLGrammar      `cmd:"" help:"get key ttl (seconds), 0 if no ttl, <nil> if key doesn't exist'"`
	RWBegin  RWBeginGrammar  `cmd:"" name:"rwbegin" help:"begin a read/write transaction"`
	RBegin   RBeginGrammar   `cmd:"" name:"rbegin" help:"begin a readonly transaction"`
	Commit   CommitGrammar   `cmd:"" help:"commit a transaction"`
	Rollback RollbackGrammar `cmd:"" help:"rollback a transaction"`
	Shrink   ShrinkGrammar   `cmd:"" help:"run database shrink command"`
	Save     SaveGrammar     `cmd:"" help:"save the db to file"`
	Drop     DropGrammar     `cmd:"" help:"drop command"`
	Search   SearchGrammar   `cmd:"" help:"Search for a string contained in any values"`
	Help     HelpGrammar     `cmd:"" help:"show available command"`
	DBSize   DBSizeGrammar   `cmd:"" name:"dbsize" help:"show db size"`
	Exit     bool            `kong:"-"`
}

func NewGrammar

func NewGrammar() *Grammar

func (*Grammar) ExitWrapper

func (g *Grammar) ExitWrapper(int)

type HelpGrammar added in v0.0.7

type HelpGrammar struct {
}

func (*HelpGrammar) Run added in v0.0.7

func (h *HelpGrammar) Run(ctx *kong.Context) (err error)

type KeysGrammar

type KeysGrammar struct {
	Pattern string `arg:"" help:"the match pattern "`
}

func (KeysGrammar) Run

func (k KeysGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type RBeginGrammar added in v0.0.2

type RBeginGrammar struct{}

func (*RBeginGrammar) Run added in v0.0.2

func (r *RBeginGrammar) Run(ctx *kong.Context) error

type RWBeginGrammar added in v0.0.2

type RWBeginGrammar struct{}

func (*RWBeginGrammar) Run added in v0.0.2

func (r *RWBeginGrammar) Run(ctx *kong.Context) error

type RollbackGrammar added in v0.0.2

type RollbackGrammar struct{}

func (*RollbackGrammar) Run added in v0.0.2

func (r *RollbackGrammar) Run(ctx *kong.Context) error

type SaveGrammar added in v0.0.3

type SaveGrammar struct {
	Path  string `arg:"" help:"the path to save"`
	Force bool   `optional:"" help:"overwrite if the path exists"`
}

func (*SaveGrammar) Run added in v0.0.3

func (s *SaveGrammar) Run(ctx *kong.Context) error

type SearchGrammar added in v0.0.7

type SearchGrammar struct {
	Pattern string `arg:"" help:"the match pattern "`
	Delete  bool   `optional:"" short:"c" help:"delete all keys found (DANGEROUS)"`
}

func (SearchGrammar) Run added in v0.0.7

func (s SearchGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type SetGrammar

type SetGrammar struct {
	Key   string `arg:"" help:"the key to set"`
	Value string `arg:"" help:"the value assign to the key"`
	TTL   int64  `arg:"" optional:"" help:"expire time in second"`
}

func (*SetGrammar) Run

func (s *SetGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type ShowGrammar

type ShowGrammar struct {
	Cmd string `arg:"" enum:"db,index"`
}

func (*ShowGrammar) Run

func (s *ShowGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type ShrinkGrammar added in v0.0.3

type ShrinkGrammar struct{}

func (*ShrinkGrammar) Run added in v0.0.3

func (s *ShrinkGrammar) Run(ctx *kong.Context) error

type TTLGrammar

type TTLGrammar struct {
	Key string `arg:"" help:"the key to show ttl"`
}

func (*TTLGrammar) Run

func (t *TTLGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

type UseGrammar

type UseGrammar struct {
	Path   string `arg:"" help:"the new db path"`
	Create bool   `optional:"" short:"c" help:"create new db if path doesn't exist'"`
}

func (*UseGrammar) Run

func (u *UseGrammar) Run(ctx *kong.Context, tx *buntdb.Tx) error

Jump to

Keyboard shortcuts

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