utils

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: GPL-3.0 Imports: 12 Imported by: 6

Documentation

Overview

Package utils provides common sub commands and command flags.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DataDirFlag --datadir
	DataDirFlag = &cli.StringFlag{
		Name:  "datadir",
		Usage: "data directory",
		Value: "",
	}
	// ConfigFileFlag -c|--config
	ConfigFileFlag = &cli.StringFlag{
		Name:    "config",
		Aliases: []string{"c"},
		Usage:   "Specify config file",
	}
	// TokenPairsDirFlag --pairsdir
	TokenPairsDirFlag = &cli.StringFlag{
		Name:  "pairsdir",
		Usage: "Specify token pairs directory",
	}
	// LogFileFlag --log
	LogFileFlag = &cli.StringFlag{
		Name:  "log",
		Usage: "Specify log file, support rotate",
	}
	// LogRotationFlag --rotate
	LogRotationFlag = &cli.Uint64Flag{
		Name:  "rotate",
		Usage: "log rotation time (unit hour)",
		Value: 24,
	}
	// LogMaxAgeFlag --maxage
	LogMaxAgeFlag = &cli.Uint64Flag{
		Name:  "maxage",
		Usage: "log max age (unit hour)",
		Value: 720,
	}
	// VerbosityFlag -v|--verbosity
	VerbosityFlag = &cli.Uint64Flag{
		Name:    "verbosity",
		Aliases: []string{"v"},
		Usage:   "log verbosity (0:panic, 1:fatal, 2:error, 3:warn, 4:info, 5:debug, 6:trace)",
		Value:   4,
	}
	// JSONFormatFlag --json
	JSONFormatFlag = &cli.BoolFlag{
		Name:  "json",
		Usage: "output log in json format",
	}
	// ColorFormatFlag --color
	ColorFormatFlag = &cli.BoolFlag{
		Name:  "color",
		Usage: "output log in color text format",
		Value: true,
	}
	// StartHeightFlag --start
	StartHeightFlag = &cli.Uint64Flag{
		Name:  "start",
		Usage: "start height (start inclusive)",
	}
	// EndHeightFlag --end
	EndHeightFlag = &cli.Uint64Flag{
		Name:  "end",
		Usage: "end height (end exclusive)",
	}
	// StableHeightFlag --stable
	StableHeightFlag = &cli.Uint64Flag{
		Name:  "stable",
		Usage: "stable height",
		Value: 5,
	}
	// JobsFlag --jobs
	JobsFlag = &cli.Uint64Flag{
		Name:  "jobs",
		Usage: "number of jobs",
		Value: 4,
	}
	// GatewayFlag --gateway
	GatewayFlag = &cli.StringFlag{
		Name:  "gateway",
		Usage: "gateway URL to connect",
	}
	// SwapServerFlag --swapserver
	SwapServerFlag = &cli.StringFlag{
		Name:  "swapserver",
		Usage: "swap server RPC address",
	}
	// DcrmAddressFlag --dcrmAddress
	DcrmAddressFlag = &cli.StringFlag{
		Name:  "dcrmAddress",
		Usage: "dcrm address",
	}
	// DepositAddressSliceFlag --deposit
	DepositAddressSliceFlag = &cli.StringSliceFlag{
		Name:  "deposit",
		Usage: "deposit address slice",
	}
	// DepositAddressFlag --deposit
	DepositAddressFlag = &cli.StringFlag{
		Name:  "deposit",
		Usage: "deposit address",
	}
	// TokenAddressSliceFlag --token
	TokenAddressSliceFlag = &cli.StringSliceFlag{
		Name:  "token",
		Usage: "token address slice",
	}
	// PairIDSliceFlag --pairid
	PairIDSliceFlag = &cli.StringSliceFlag{
		Name:  "pairid",
		Usage: "token pair id slice",
	}
	// KeystoreFileFlag --keystore
	KeystoreFileFlag = &cli.StringFlag{
		Name:  "keystore",
		Usage: "keystore file",
	}
	// PasswordFileFlag --password
	PasswordFileFlag = &cli.StringFlag{
		Name:  "password",
		Usage: "password file",
	}
	// SwapTypeFlag --swaptype
	SwapTypeFlag = &cli.StringFlag{
		Name:  "swaptype",
		Usage: "value can be swapin or swapout",
		Value: "swapin",
	}
)
View Source
var (
	CleanupChan  = make(chan struct{})
	TopWaitGroup = new(sync.WaitGroup)
)

catch signal and cleanup related

View Source
var (
	// LicenseCommand license cubcommonad
	LicenseCommand = &cli.Command{
		Action:    license,
		Name:      "license",
		Usage:     "Display license information",
		ArgsUsage: " ",
	}
)
View Source
var (
	// VersionCommand version subcommand
	VersionCommand = &cli.Command{
		Action:    version,
		Name:      "version",
		Usage:     "Print version numbers",
		ArgsUsage: " ",
		Description: `
The output of this command is supposed to be machine-readable.
`,
	}
)

Functions

func GetConfigFilePath

func GetConfigFilePath(ctx *cli.Context) string

GetConfigFilePath specified by `-c|--config`

func GetDataDir added in v0.3.7

func GetDataDir(ctx *cli.Context) string

GetDataDir specified by `--datadir`

func GetTokenPairsDir added in v0.3.0

func GetTokenPairsDir(ctx *cli.Context) string

GetTokenPairsDir specified by `--pairsdir`

func IsCleanuping added in v0.3.7

func IsCleanuping() bool

IsCleanuping is cleanuping

func NewApp

func NewApp(identifier, gitcommit, gitdate, usage string) *cli.App

NewApp creates an app with sane defaults.

func SetLogger

func SetLogger(ctx *cli.Context)

SetLogger set log level, json format, color, rotate ...

func WaitAndCleanup added in v0.3.7

func WaitAndCleanup(doCleanup func())

WaitAndCleanup wait and cleanup

Types

This section is empty.

Jump to

Keyboard shortcuts

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