shelly

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 5 Imported by: 0

README

Build Status (master)

Shelly

This Go package provides a basic API for creating a shell programs.

Feature list:

  • Tab completion
  • Complex commands that can have an arbitrary number of sub-commands and parameters
  • History

Dependencies

It uses the amazing termbox-go package. Check it out.

Installation

Run the following commands to install shelly-go and it's dependencies:

 $ go get github.com/lunjon/shelly-go
 $ cd <path to shelly-go>
 $ go get ./...

Examples

See ./cmd/shelly for an example program (showed briefly in the GIF below).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoCompleteMenu added in v0.0.6

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

AutoCompleteMenu displays a set of items to select from

func (*AutoCompleteMenu) Backspace added in v0.0.6

func (m *AutoCompleteMenu) Backspace()

func (*AutoCompleteMenu) Display added in v0.0.6

func (m *AutoCompleteMenu) Display()

Display the menu

func (*AutoCompleteMenu) Enter added in v0.0.6

func (m *AutoCompleteMenu) Enter()

func (*AutoCompleteMenu) NavigateLeft added in v0.0.6

func (m *AutoCompleteMenu) NavigateLeft()

NavigateLeft moves to the item left of the currently selected item

func (*AutoCompleteMenu) NavigateRight added in v0.0.6

func (m *AutoCompleteMenu) NavigateRight()

NavigateRight moves to the item right of the currently selected item

func (*AutoCompleteMenu) Selected added in v0.0.6

func (m *AutoCompleteMenu) Selected() string

Selected returns the currently selected item

func (*AutoCompleteMenu) Tab added in v0.0.6

func (m *AutoCompleteMenu) Tab()

Tab moves moves the selection to the right

type ColorScheme added in v0.0.4

type ColorScheme int

ColorScheme defines a type aliases for color schemes

const (
	// DefaultColorScheme has black background and white foreground
	DefaultColorScheme ColorScheme = iota
	// LightColorScheme has white background and black foreground
	LightColorScheme ColorScheme = iota
)

type Shell

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

Shell is a basic command dispatcher with tab completion, history, and more. It only requires commands to be added and may then be started by calling Start().

func NewShell

func NewShell(prompt string) (*Shell, error)

NewShell creates a new shell with the given prompt.

func (*Shell) AddCommand

func (shell *Shell) AddCommand(cmd *command.Command) error

AddCommand appends cmd the list of available commands for this REPL

func (*Shell) Print added in v0.0.5

func (shell *Shell) Print(data ...interface{})

Print writes str to the shells output, which is used to get text output during execution.

func (*Shell) Printf added in v0.0.5

func (shell *Shell) Printf(format string, data ...interface{})

Printf writes str as a format string to the shells output, which is used to get text output during execution. The number of lines that can be written is limited to the current size of the terminal.

func (*Shell) SetColorScheme added in v0.0.4

func (shell *Shell) SetColorScheme(cs ColorScheme) error

SetColorScheme to cs

func (*Shell) Start

func (shell *Shell) Start()

Start the shell.

type TermboxWindow added in v0.0.6

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

TermboxWindow represents a rolling window.

func NewTermboxWindow added in v0.0.6

func NewTermboxWindow(yStart, indent, height int, fg, bg termbox.Attribute) (*TermboxWindow, error)

NewTermboxWindow ...

func (*TermboxWindow) Display added in v0.0.6

func (window *TermboxWindow) Display()

Display ...

func (*TermboxWindow) Print added in v0.0.6

func (window *TermboxWindow) Print(data ...interface{})

Print ...

func (*TermboxWindow) Printf added in v0.0.6

func (window *TermboxWindow) Printf(format string, data ...interface{})

Printf ...

func (*TermboxWindow) Reset added in v0.0.6

func (window *TermboxWindow) Reset()

Reset ...

func (*TermboxWindow) ScrollDown added in v0.0.6

func (window *TermboxWindow) ScrollDown(height int)

ScrollDown ...

func (*TermboxWindow) ScrollUp added in v0.0.6

func (window *TermboxWindow) ScrollUp(height int)

ScrollUp ...

func (*TermboxWindow) SetHeight added in v0.0.6

func (window *TermboxWindow) SetHeight(height int)

SetHeight ...

Directories

Path Synopsis
cmd
examples
internal

Jump to

Keyboard shortcuts

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