cli

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP  = "RDS"
	VER  = "1.11.2"
	DESC = "Tool for Redis orchestration"
)
View Source
const (
	OPT_PRIVATE       = "p:private"
	OPT_EXTRA         = "x:extra"
	OPT_TAGS          = "t:tags"
	OPT_FORMAT        = "f:format"
	OPT_SECURE        = "s:secure"
	OPT_DISABLE_SAVES = "ds:disable-saves"
	OPT_YES           = "y:yes"
	OPT_PAGER         = "P:pager"
	OPT_SIMPLE        = "S:simple"
	OPT_RAW           = "R:raw"
	OPT_NO_COLOR      = "nc:no-color"
	OPT_HELP          = "h:help"
	OPT_VERSION       = "v:version"

	OPT_VERBOSE_VERSION = "vv:verbose-version"
	OPT_GENERATE_MAN    = "generate-man"
	OPT_COMPLETION      = "completion"
)

Command line options list

View Source
const (
	COMMAND_BACKUP_CREATE        = "backup-create"
	COMMAND_BACKUP_RESTORE       = "backup-restore"
	COMMAND_BACKUP_CLEAN         = "backup-clean"
	COMMAND_BACKUP_LIST          = "backup-list"
	COMMAND_BATCH_CREATE         = "batch-create"
	COMMAND_BATCH_EDIT           = "batch-edit"
	COMMAND_CHECK                = "check"
	COMMAND_CLI                  = "cli"
	COMMAND_CLIENTS              = "clients"
	COMMAND_CPU                  = "cpu"
	COMMAND_CONF                 = "conf"
	COMMAND_CREATE               = "create"
	COMMAND_DELETE               = "delete"
	COMMAND_DESTROY              = "destroy"
	COMMAND_EDIT                 = "edit"
	COMMAND_GEN_TOKEN            = "gen-token"
	COMMAND_GO                   = "go"
	COMMAND_HELP                 = "help"
	COMMAND_INFO                 = "info"
	COMMAND_INIT                 = "init"
	COMMAND_KILL                 = "kill"
	COMMAND_LIST                 = "list"
	COMMAND_LOG                  = "log"
	COMMAND_MAINTENANCE          = "maintenance"
	COMMAND_MEMORY               = "memory"
	COMMAND_REGEN                = "regen"
	COMMAND_RELEASE              = "release"
	COMMAND_RELOAD               = "reload"
	COMMAND_REMOVE               = "remove"
	COMMAND_REPLICATION          = "replication"
	COMMAND_REPLICATION_ROLE_SET = "replication-role-set"
	COMMAND_RESTART              = "restart"
	COMMAND_RESTART_ALL          = "restart-all"
	COMMAND_RESTART_ALL_PROP     = "@" + COMMAND_RESTART_ALL
	COMMAND_RESTART_PROP         = "@" + COMMAND_RESTART
	COMMAND_SENTINEL_CHECK       = "sentinel-check"
	COMMAND_SENTINEL_INFO        = "sentinel-info"
	COMMAND_SENTINEL_MASTER      = "sentinel-master"
	COMMAND_SENTINEL_RESET       = "sentinel-reset"
	COMMAND_SENTINEL_START       = "sentinel-start"
	COMMAND_SENTINEL_STATUS      = "sentinel-status"
	COMMAND_SENTINEL_STOP        = "sentinel-stop"
	COMMAND_SENTINEL_SWITCH      = "sentinel-switch-master"
	COMMAND_SETTINGS             = "settings"
	COMMAND_SLOWLOG_GET          = "slowlog-get"
	COMMAND_SLOWLOG_RESET        = "slowlog-reset"
	COMMAND_START                = "start"
	COMMAND_START_ALL            = "start-all"
	COMMAND_START_ALL_PROP       = "@" + COMMAND_START_ALL
	COMMAND_START_PROP           = "@" + COMMAND_START
	COMMAND_STATE_RESTORE        = "state-restore"
	COMMAND_STATE_SAVE           = "state-save"
	COMMAND_STATS                = "stats"
	COMMAND_STATS_COMMAND        = "stats-command"
	COMMAND_STATS_LATENCY        = "stats-latency"
	COMMAND_STATS_ERROR          = "stats-error"
	COMMAND_STATUS               = "status"
	COMMAND_STOP                 = "stop"
	COMMAND_STOP_ALL             = "stop-all"
	COMMAND_STOP_ALL_PROP        = "@" + COMMAND_STOP_ALL
	COMMAND_STOP_PROP            = "@" + COMMAND_STOP
	COMMAND_TAG_ADD              = "tag-add"
	COMMAND_TAG_REMOVE           = "tag-remove"
	COMMAND_TOP                  = "top"
	COMMAND_TOP_DIFF             = "top-diff"
	COMMAND_TOP_DUMP             = "top-dump"
	COMMAND_TRACK                = "track"
	COMMAND_VALIDATE_TEMPLATES   = "validate-templates"
	COMMAND_UPTIME               = "uptime"
)

Supported commands

View Source
const (
	FORMAT_TEXT = "text"
	FORMAT_JSON = "json"
	FORMAT_XML  = "xml"
)
View Source
const (
	EC_OK     = 0
	EC_ERROR  = 1
	EC_WARN   = 2
	EC_CANCEL = 3
)
View Source
const (
	BACKUP_PERMS = 0600 // Default permissions for backups
	MAX_BACKUPS  = 10   // Maximum number of backups
)
View Source
const (
	LOG_SOURCE_CLI  = "cli"
	LOG_SOURCE_SYNC = "sync"
)
View Source
const CONFIG_FILE = "/etc/rds.knf"

CONFIG_FILE is path to configuration file

View Source
const EMPTY_RESULT = "-none-"

EMPTY_RESULT is default value for an empty result from Redis

View Source
const MAINTENANCE_LOCK_FILE = ".maintenance"

MAINTENANCE_LOCK_FILE is name of lock file from maintenance mode

View Source
const MAX_DESC_LENGTH = 64

MAX_DESC_LENGTH is maximum width of description line

Variables

View Source
var FilteredProps = []string{
	"masterauth",
	"masteruser",
	"rename-command",
	"requirepass",
	"user",
}

FilteredProps is a slice with props that must not be shown in the command output

Functions

func BackupCleanCommand added in v1.2.0

func BackupCleanCommand(args CommandArgs) int

BackupCleanCommand is "backup-clean" command handler

func BackupCreateCommand added in v1.2.0

func BackupCreateCommand(args CommandArgs) int

BackupCreateCommand is "backup-create" command handler

func BackupListCommand added in v1.2.0

func BackupListCommand(args CommandArgs) int

BackupListCommand is "backup-list" command handler

func BackupRestoreCommand added in v1.2.0

func BackupRestoreCommand(args CommandArgs) int

BackupRestoreCommand is "backup-restore" command handler

func BatchCreateCommand

func BatchCreateCommand(args CommandArgs) int

BatchCreateCommand is "batch-create" command handler

func BatchEditCommand

func BatchEditCommand(args CommandArgs) int

BatchEditCommand is "batch-edit" command handler

func CPUCommand

func CPUCommand(args CommandArgs) int

CPUCommand is "cpu" command handler

func CheckCommand

func CheckCommand(args CommandArgs) int

CheckCommand is "check" command handler

func CliCommand

func CliCommand(args CommandArgs) int

CliCommand is "cli" command handler

func ClientsCommand

func ClientsCommand(args CommandArgs) int

ClientsCommand is "clients" command handler

func ConfCommand

func ConfCommand(args CommandArgs) int

ConfCommand is "conf" command handler

func CreateCommand

func CreateCommand(args CommandArgs) int

CreateCommand is "create" command handler

func DestroyCommand

func DestroyCommand(args CommandArgs) int

DestroyCommand is "destroy" command handler

func EditCommand

func EditCommand(args CommandArgs) int

EditCommand is "edit" command handler

func GenTokenCommand

func GenTokenCommand(args CommandArgs) int

GenTokenCommand is "gen-token" command handler

func GoCommand

func GoCommand(args CommandArgs) int

GoCommand is "go" command handler

func HelpCommand

func HelpCommand(args CommandArgs) int

HelpCommand is "go" command handler

func InfoCommand

func InfoCommand(args CommandArgs) int

InfoCommand is "info" command handler

func Init

func Init(gitRev string, gomod []byte)

Init is main function

func KillCommand

func KillCommand(args CommandArgs) int

KillCommand is "kill" command handler

func ListCommand

func ListCommand(args CommandArgs) int

ListCommand is "list" command handler

func LogCommand added in v1.8.0

func LogCommand(args CommandArgs) int

LogCommand is "log" command handler

func MaintenanceCommand

func MaintenanceCommand(args CommandArgs) int

MaintenanceCommand is "maintenance" command handler

func MemoryCommand

func MemoryCommand(args CommandArgs) int

MemoryCommand is "memory" command handler

func RegenCommand

func RegenCommand(args CommandArgs) int

RegenCommand is "regen" command handler

func ReloadCommand

func ReloadCommand(args CommandArgs) int

ReloadCommand is "reload" command handler

func ReplicationCommand

func ReplicationCommand(args CommandArgs) int

ReplicationCommand is "replication" command handler

func ReplicationRoleSetCommand

func ReplicationRoleSetCommand(args CommandArgs) int

ReplicationCommand is "replication" command handler

func RestartAllCommand

func RestartAllCommand(args CommandArgs) int

RestartAllCommand is "restart-all" command handler

func RestartAllPropCommand

func RestartAllPropCommand(args CommandArgs) int

RestartAllPropCommand is "@restart-all" command handler

func RestartCommand

func RestartCommand(args CommandArgs) int

RestartCommand is "restart" command handler

func RestartPropCommand

func RestartPropCommand(args CommandArgs) int

RestartPropCommand is "@restart" command handler

func RestoreStateCommand

func RestoreStateCommand(args CommandArgs) int

RestoreStateCommand is "state-restore" command handler

func SaveStateCommand

func SaveStateCommand(args CommandArgs) int

SaveStateCommand is "state-save" command handler

func SentinelCheckCommand

func SentinelCheckCommand(args CommandArgs) int

SentinelCheckCommand is "sentinel-check" command handler

func SentinelInfoCommand

func SentinelInfoCommand(args CommandArgs) int

SentinelInfoCommand is "sentinel-info" command handler

func SentinelMasterCommand

func SentinelMasterCommand(args CommandArgs) int

SentinelMasterCommand is "sentinel-master" command handler

func SentinelResetCommand

func SentinelResetCommand(args CommandArgs) int

SentinelResetCommand is "sentinel-reset" command handler

func SentinelStartCommand

func SentinelStartCommand(args CommandArgs) int

SentinelStartCommand is "sentinel-start" command handler

func SentinelStatusCommand

func SentinelStatusCommand(args CommandArgs) int

SentinelStatusCommand is "sentinel-status" command handler

func SentinelStopCommand

func SentinelStopCommand(args CommandArgs) int

SentinelStopCommand is "sentinel-stop" command handler

func SentinelSwitchMasterCommand

func SentinelSwitchMasterCommand(args CommandArgs) int

SentinelSwitchMasterCommand is "sentinel-switch-master" command handler

func SettingsCommand

func SettingsCommand(args CommandArgs) int

StopAllCommand is "settings" command handler

func SlowlogGetCommand

func SlowlogGetCommand(args CommandArgs) int

SlowlogGetCommand is "slowlog-get" command handler

func SlowlogResetCommand

func SlowlogResetCommand(args CommandArgs) int

SlowlogResetCommand is "slowlog-reset" command handler

func StartAllCommand

func StartAllCommand(args CommandArgs) int

StartAllCommand is "start-all" command handler

func StartAllPropCommand

func StartAllPropCommand(args CommandArgs) int

StartAllPropCommand is "@start-all" command handler

func StartCommand

func StartCommand(args CommandArgs) int

StartCommand is "start" command handler

func StartPropCommand

func StartPropCommand(args CommandArgs) int

StartPropCommand is "@start" command handler

func StatsCommand

func StatsCommand(args CommandArgs) int

StatsCommand is "stats" command handler

func StatsCommandCommand

func StatsCommandCommand(args CommandArgs) int

StatsCommandCommand is "stats-command" command handler

func StatsErrorCommand

func StatsErrorCommand(args CommandArgs) int

StatsErrorCommand is "stats-error" command handler

func StatsLatencyCommand

func StatsLatencyCommand(args CommandArgs) int

StatsLatencyCommand is "stats-latency" command handler

func StatusCommand

func StatusCommand(args CommandArgs) int

StatusCommand is "status" command handler

func StopAllCommand

func StopAllCommand(args CommandArgs) int

StopAllCommand is "stop-all" command handler

func StopAllPropCommand

func StopAllPropCommand(args CommandArgs) int

StopAllPropCommand is "@stop-all" command handler

func StopCommand

func StopCommand(args CommandArgs) int

StopCommand is "stop" command handler

func StopPropCommand

func StopPropCommand(args CommandArgs) int

StopPropCommand is "@stop" command handler

func TagAddCommand

func TagAddCommand(args CommandArgs) int

TagAddCommand is "tag-add" command handler

func TagRemoveCommand

func TagRemoveCommand(args CommandArgs) int

TagRemoveCommand is "tag-remove" command handler

func TopCommand

func TopCommand(args CommandArgs) int

TopCommand is "top" command handler

func TopDiffCommand

func TopDiffCommand(args CommandArgs) int

TopDiffCommand is "top-diff" command handler

func TopDumpCommand

func TopDumpCommand(args CommandArgs) int

TopDumpCommand is "top-dump" command handler

func TrackCommand

func TrackCommand(args CommandArgs) int

TrackCommand is "track" command handler

func UptimeCommand added in v1.11.0

func UptimeCommand(args CommandArgs) int

UptimeCommand is "uptime" command handler

func ValidateTemplatesCommand added in v1.2.0

func ValidateTemplatesCommand(args CommandArgs) int

ValidateTemplatesCommand is "validate-templates" command handler

Types

type AuthFlag added in v1.6.0

type AuthFlag uint8
const (
	AUTH_NO AuthFlag = 1 << iota
	AUTH_INSTANCE
	AUTH_SUPERUSER
	AUTH_STRICT
)

func (AuthFlag) Has added in v1.6.0

func (f AuthFlag) Has(flag AuthFlag) bool

type CommandArgs

type CommandArgs []string

func (CommandArgs) Check

func (a CommandArgs) Check(mustWorks bool) error

Check checks command arguments

func (CommandArgs) Get

func (a CommandArgs) Get(index int) string

Get returns argument with given index

func (CommandArgs) GetB

func (a CommandArgs) GetB(index int) (bool, error)

GetB returns argument with given index as boolean

func (CommandArgs) GetF

func (a CommandArgs) GetF(index int) (float64, error)

GetF returns argument with given index as float

func (CommandArgs) GetI

func (a CommandArgs) GetI(index int) (int, error)

GetI returns argument with given index as int

func (CommandArgs) Has

func (a CommandArgs) Has(index int) bool

Has returns true if arguments contains argument with given index

type CommandHandler

type CommandHandler func(CommandArgs) int

type CommandRoutine

type CommandRoutine struct {
	Handler      CommandHandler
	Auth         AuthFlag
	PrettyOutput bool
}

type Logger added in v1.2.0

type Logger struct{}

func (*Logger) Debug added in v1.2.0

func (l *Logger) Debug(id int, f string, a ...any) error

Error writes debug message to CLI log

func (*Logger) Error added in v1.2.0

func (l *Logger) Error(id int, f string, a ...any) error

Error writes error message to CLI log

func (*Logger) Info added in v1.2.0

func (l *Logger) Info(id int, f string, a ...any) error

Error writes info message to CLI log

func (*Logger) Warn added in v1.2.0

func (l *Logger) Warn(id int, f string, a ...any) error

Error writes warning message to CLI log

type Preferences added in v1.5.0

type Preferences struct {
	DisableTips     bool
	EnablePowerline bool
	SimpleUI        bool
	AutoPaging      bool
}

Preferences struct contains user-specific preferences

func GetPreferences added in v1.5.0

func GetPreferences() Preferences

GetPreferences reads preferences defined by current user

Jump to

Keyboard shortcuts

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