cmd

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: ISC Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APPNAME    = "9"
	APPDESC    = "all in one everything for parallelcoin"
	APPVERSION = "v1.9.9"

	HELP, RE_HELP       = "help", "(h|help)"
	CONF, RE_CONF       = "conf", "(C|conf)"
	NEW, RE_NEW         = "new", "(N|new)"
	COPY, RE_COPY       = "copy", "(cp|copy)"
	LIST, RE_LIST       = "list", "(l|list|listcommands)"
	CTL, RE_CTL         = "ctl", "(c|ctl)"
	NODE, RE_NODE       = "node", "(n|node)"
	WALLET, RE_WALLET   = "wallet", "(w|wallet)"
	SHELL, RE_SHELL     = "shell", "(s|shell)"
	TEST, RE_TEST       = "test", "(t|test)"
	CREATE, RE_CREATE   = "create", "(cr|create)"
	LOG, RE_LOG         = "log", "(L|log)"
	DATADIR, RE_DATADIR = "datadir", "(([A-Za-z][:])|[\\~/.]+.*)"
	INTEGER, RE_INTEGER = "integer", "[0-9]+"
	FLOAT, RE_FLOAT     = "float", "([0-9]*[.][0-9]+)"
	WORD, RE_WORD       = "word", "([a-zA-Z0-9._-]+)"
)

Variables

View Source
var Config = MakeConfig(config)
View Source
var ConfigFile string
View Source
var DataDir string
View Source
var Networks = []string{"mainnet", "testnet", "simnet", "regtestnet"}

Functions

func CleanAndExpandPath

func CleanAndExpandPath(path string) string

CleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it.

func Conf

func Conf(args []string, tokens Tokens, cmds, all Commands) int

func Copy

func Copy(args []string, tokens Tokens, cmds, all Commands) int

func Create

func Create(args []string, tokens Tokens, cmds, all Commands) int

func Ctl

func Ctl(args []string, tokens Tokens, cmds, all Commands) int

func EnsureDir

func EnsureDir(fileName string) bool

EnsureDir checks a file could be written to a path, creates the directories as needed

func FileExists

func FileExists(filePath string) bool

FileExists reports whether the named file or directory exists.

func Help

func Help(args []string, tokens Tokens, cmds, all Commands) int

func List

func List(args []string, tokens Tokens, cmds, all Commands) int

func MakeConfig

func MakeConfig(c *Lines) (out *nine.Config)

func New

func New(args []string, tokens Tokens, cmds, all Commands) int

func Node

func Node(args []string, tokens Tokens, cmds, all Commands) int

func NormalizeAddress

func NormalizeAddress(addr, defaultPort string) string

NormalizeAddress returns addr with the passed default port appended if there is not already a port specified.

func NormalizeAddresses

func NormalizeAddresses(addrs []string, defaultPort string) []string

NormalizeAddresses returns a new slice with all the passed peer addresses normalized with the given default port, and all duplicates removed.

func Parse

func Parse(args []string) int

func RemoveDuplicateAddresses

func RemoveDuplicateAddresses(addrs []string) []string

RemoveDuplicateAddresses returns a new slice with all duplicate entries in addrs removed.

func Shell

func Shell(args []string, tokens Tokens, cmds, all Commands) int

func Start

func Start(args []string) int

func Test

func Test(args []string, tokens Tokens, cmds, all Commands) int

func ValidName

func ValidName(s string) bool

ValidName checks to see a name is a valid name - first letter alphabetical, last alpha/numeric, all between also . and -

func Wallet

func Wallet(args []string, tokens Tokens, cmds, all Commands) int

Types

type Command

type Command struct {

	// How to identify a specific item
	RE *regexp.Regexp
	// Short help information to show
	Usage string
	// Detailed information to show on specific help page
	Detail string
	// Optional keywords that may appear with the command
	Optional opts
	// Precedent indicates other commands that will preferentially match
	Precedent precedent
	// Handler
	Handler func(args []string, tokens Tokens, cmds, all Commands) int
	// contains filtered or unexported fields
}

Command is a set-based syntax for command line invocation. A set has a more limited range of possibilities when an item type cannot appear more than once, but for any given task, there usually is only one thing for each type required.

If more detailed stuff is needed, we provide access through a configuration interactive CLI.

nil values in opt/prec indicate wildcards, empty means no other acceptable.

type Commands

type Commands map[string]Command

type Line

type Line struct {
	// Name is here so we can detach from the map but know the name to refer to
	// it when it is stored in a map
	Name string
	// Initial is the default for this value
	Initial interface{}
	// Validate returns true if the string is properly formed for the type
	Validate func(*Line, interface{}) bool
	// The help string that will be shown by the interactive config system and
	// cli help
	Comment string
	// Value is where this value is actually stored
	Value interface{}
}

Line is a configuration line, made into map becomes a configuration thingy that has set-like properties.

func Addr

func Addr(s string) *Line

func Addrs

func Addrs(s string) *Line

func Algo

func Algo(s string) *Line

func Dir

func Dir(s string) *Line

func Duration

func Duration(s string) *Line

func Enable

func Enable(s string) *Line

Enable is a boolean that defaults to false

func Enabled

func Enabled(s string) (o *Line)

Enabled is a boolean that defaults to true

func File

func File(s string) *Line

func Float

func Float(s string) *Line

func Int

func Int(s string) *Line

func Log

func Log(s string) *Line

func Net

func Net(s string) (o *Line)

func Port

func Port(s string) *Line

func Tag

func Tag(s string) *Line

func Tags

func Tags(s string) *Line

func (*Line) BOOL

func (l *Line) BOOL(v ...bool) *bool

func (*Line) Default

func (l *Line) Default(d interface{}) (out *Line)

Default sets a default value for the Line

func (*Line) FLOAT

func (l *Line) FLOAT(v ...float64) *float64

func (*Line) INT

func (l *Line) INT(v ...int) *int

func (*Line) Label

func (l *Line) Label(name string) *Line

func (*Line) MAP

func (*Line) Max

func (l *Line) Max(i int) *Line

Max is chained to validate at initialisation

func (*Line) Min

func (l *Line) Min(i int) *Line

Min is chained to validate at initialisation

func (*Line) SLICE

func (l *Line) SLICE(v ...[]string) *[]string

func (*Line) STRING

func (l *Line) STRING(v ...string) *string

func (*Line) Usage

func (l *Line) Usage(s string) *Line

Usage is the short text explaining a configuration option

type Lines

type Lines map[string]*Line

func NewConfig

func NewConfig() *Lines

func (*Lines) Group

func (l *Lines) Group(s string, items ...*Line) (out *Lines)

func (Lines) String

func (l Lines) String() (out string)

type Stringslice

type Stringslice []string

func (Stringslice) String

func (s Stringslice) String() (out string)

type Token

type Token struct {
	Value string
	Cmd   Command
}

Token is a struct that ties together CLI invocation to the Command it relates to

type Tokens

type Tokens map[string]Token

Jump to

Keyboard shortcuts

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