cli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cli provides all methods to control command line functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CMDRgx added in v0.2.4

func CMDRgx() *regexp.Regexp

CMDRgx returns commands regex for validation

func Flag added in v0.1.8

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

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

func GetCMDNames added in v0.2.3

func GetCMDNames(s interface{}) []string

GetCMDNames returns command line names

func GetOptions added in v0.2.3

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

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

func InitConfig added in v0.2.3

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

InitConfig creates new config file

func SetConfig added in v0.2.3

func SetConfig(args string, s *Config) error

SetConfig handles update option's value

func SetFlag added in v0.1.8

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

SetFlag returns command option(s)

func SetValue added in v0.2.3

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

SetValue set optioni's value

func ShowConfig added in v0.2.3

func ShowConfig(s *Config)

ShowConfig prints the configuration

func UpgradeConfig added in v0.2.3

func UpgradeConfig(cfg *Config) error

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

func WriteConfig added in v0.2.3

func WriteConfig(cfg Config) error

WriteConfig write config to disk

Types

type Config added in v0.2.3

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 added in v0.2.3

func LoadConfig() Config

LoadConfig loads configuration

func ReadConfig added in v0.2.3

func ReadConfig() Config

ReadConfig reads configuration from existing or default configuration

func ReadDefaultConfig added in v0.2.3

func ReadDefaultConfig() (Config, error)

ReadDefaultConfig returns default configuration

type HPing added in v0.2.3

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 added in v0.2.3

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

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

Readline structure

func Init

func Init(version string) *Readline

Init set readline imain items

func (*Readline) AddCompleter

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

AddCompleter updates subitem(s) from a specific main item

func (*Readline) Close

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

Close the readline instance

func (*Readline) GetPrompt

func (r *Readline) GetPrompt() string

GetPrompt returns the current prompt string

func (*Readline) Help

func (r *Readline) Help()

Help print out the main help

func (*Readline) Next

func (r *Readline) Next()

Next trigers to read next line

func (*Readline) Refresh

func (r *Readline) Refresh()

Refresh prompt

func (*Readline) RemoveItemCompleter

func (r *Readline) RemoveItemCompleter(pcItem string)

RemoveItemCompleter removes subitem(s) from a specific main item

func (*Readline) Run

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

Run the main loop

func (*Readline) SetEmacs

func (r *Readline) SetEmacs()

SetEmacs set mode to emacs

func (*Readline) SetPrompt

func (r *Readline) SetPrompt(p string)

SetPrompt set readline prompt and store it

func (*Readline) SetVim

func (r *Readline) SetVim()

SetVim set mode to vim

func (*Readline) UpdateCompleter

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

UpdateCompleter updates subitem(s) from a specific main item

func (*Readline) UpdatePromptN

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

UpdatePromptN appends readline prompt

type SNMP added in v0.2.5

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 added in v0.2.3

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

Scan represents scan command options

type Trace added in v0.2.4

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

Trace represents trace command options

type Web added in v0.2.3

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

Web represents web command options

Jump to

Keyboard shortcuts

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