cli

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: MIT Imports: 9 Imported by: 137

Documentation

Overview

Package cli provides all methods to control command line functions

Index

Constants

This section is empty.

Variables

View Source
var (
	// validation command regex
	CMDReg, _ = regexp.Compile(
		`(ping|trace|bgp|lg|ns|dig|dump|disc|whois|peering|scan|hping|connect|node|local|mode|help|web|exit|quit)\s{0,1}(.*)`)
)

Functions

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

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

SetFlag returns command option(s)

Types

type Readline

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

Readline structure

func Init

func Init(prompt, 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

Jump to

Keyboard shortcuts

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