mylg: github.com/mehrdadrad/mylg/cli Index | Files

package cli

import "github.com/mehrdadrad/mylg/cli"

Package cli provides all methods to control command line functions

Index

Package Files

cli.go config.go

func CMDRgx Uses

func CMDRgx() *regexp.Regexp

CMDRgx returns commands regex for validation

func Flag Uses

func Flag(args string) (string, map[string]interface{})

Flag parses the command arguments syntax: -flag=x -flag x help

func GetCMDNames Uses

func GetCMDNames(s interface{}) []string

GetCMDNames returns command line names

func GetOptions Uses

func GetOptions(s interface{}, key string) ([]string, []interface{})

GetOptions returns option(s)/value(s) for specific command

func InitConfig Uses

func InitConfig(f string) ([]byte, error)

InitConfig creates new config file

func SetConfig Uses

func SetConfig(args string, s *Config) error

SetConfig handles update option's value

func SetFlag Uses

func SetFlag(flag map[string]interface{}, option string, v interface{}) interface{}

SetFlag returns command option(s)

func SetValue Uses

func SetValue(v reflect.Value, rec string, val interface{}) error

SetValue set optioni's value

func ShowConfig Uses

func ShowConfig(s *Config)

ShowConfig prints the configuration

func UpgradeConfig Uses

func UpgradeConfig(cfg *Config) error

UpgradeConfig adds / removes new command(s)/option(s)

func WriteConfig Uses

func WriteConfig(cfg Config) error

WriteConfig write config to disk

type Config Uses

type Config struct {
    Ping  Ping  `json:"ping"`
    Hping HPing `json:"hping"`
    Web   Web   `json:"web"`
    Scan  Scan  `json:"scan"`
    Trace Trace `json:"trace"`
    Snmp  SNMP  `json:"snmp"`
}

Config represents configuration

func LoadConfig Uses

func LoadConfig() Config

LoadConfig loads configuration

func ReadConfig Uses

func ReadConfig() Config

ReadConfig reads configuration from existing or default configuration

func ReadDefaultConfig Uses

func ReadDefaultConfig() (Config, error)

ReadDefaultConfig returns default configuration

type HPing Uses

type HPing struct {
    Timeout  string `json:"timeout" tag:"lower"`
    Interval string `json:"interval" tag:"lower"`
    Method   string `json:"method" tag:"upper"`
    Data     string `json:"data"`
    Count    int    `json:"count"`
}

HPing represents ping command options

type Ping Uses

type Ping struct {
    Timeout  string `json:"timeout" tag:"lower"`
    Interval string `json:"interval" tag:"lower"`
    Count    int    `json:"count"`
}

Ping represents ping command options

type Readline Uses

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

Readline structure

func Init Uses

func Init(version string) *Readline

Init set readline imain items

func (*Readline) AddCompleter Uses

func (r *Readline) AddCompleter(pcItem string, pcSubItems []string)

AddCompleter updates subitem(s) from a specific main item

func (*Readline) Close Uses

func (r *Readline) Close(next chan struct{})

Close the readline instance

func (*Readline) GetPrompt Uses

func (r *Readline) GetPrompt() string

GetPrompt returns the current prompt string

func (*Readline) Help Uses

func (r *Readline) Help()

Help print out the main help

func (*Readline) Next Uses

func (r *Readline) Next()

Next trigers to read next line

func (*Readline) Refresh Uses

func (r *Readline) Refresh()

Refresh prompt

func (*Readline) RemoveItemCompleter Uses

func (r *Readline) RemoveItemCompleter(pcItem string)

RemoveItemCompleter removes subitem(s) from a specific main item

func (*Readline) Run Uses

func (r *Readline) Run(cmd chan<- string, next chan struct{})

Run the main loop

func (*Readline) SetEmacs Uses

func (r *Readline) SetEmacs()

SetEmacs set mode to emacs

func (*Readline) SetPrompt Uses

func (r *Readline) SetPrompt(p string)

SetPrompt set readline prompt and store it

func (*Readline) SetVim Uses

func (r *Readline) SetVim()

SetVim set mode to vim

func (*Readline) UpdateCompleter Uses

func (r *Readline) UpdateCompleter(pcItem string, pcSubItems []string)

UpdateCompleter updates subitem(s) from a specific main item

func (*Readline) UpdatePromptN Uses

func (r *Readline) UpdatePromptN(p string, n int)

UpdatePromptN appends readline prompt

type SNMP Uses

type SNMP struct {
    Community     string `json:"community"`
    Timeout       string `json:"timeout" tag:"lower"`
    Version       string `json:"version" tag:"lower"`
    Retries       int    `json:"retries"`
    Port          int    `json:"port"`
    Securitylevel string `json:"securitylevel"`
    Authpass      string `json:"authpass"`
    Authproto     string `json:"authproto" tag:"lower"`
    Privacypass   string `json:"privacypass"`
    Privacyproto  string `json:"privacyproto" tag:"lower"`
}

SNMP represents nms command options

type Scan Uses

type Scan struct {
    Port string `json:"port"`
}

Scan represents scan command options

type Trace Uses

type Trace struct {
    Wait  string `json:"wait" tag:"lower"`
    Theme string `json:"theme" tag:"lower"`
}

Trace represents trace command options

type Web Uses

type Web struct {
    Port    int    `json:"port"`
    Address string `json:"address"`
}

Web represents web command options

Package cli imports 13 packages (graph) and is imported by 45 packages. Updated 2016-12-31. Refresh now. Tools for package owners.