cli

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: MIT Imports: 13 Imported by: 0

README

MOTKI CLI

Command motki contains interactive command-line tools for managing EVE Online character and corporation assets and industrial processes.

GoDoc

Getting started

Download the latest pre-built motki binary for your platform.

Note that the default configuration connects to motki.org:18443 using SSL.

Install with go get

Alternatively, you can install the MOTKI CLI with go get.

go get -u github.com/motki/cli/cmd/motki
Command-line options
Usage of motki:
  -credentials string
    	Username and password separated by a colon. (ie. "frank:mypass")
  -history-file string
    	Path to the CLI history file. (default ".history")
  -insecure-skip-verify
    	INSECURE: Skip verification of server SSL cert.
  -log-level string
    	Log level. Possible values: debug, info, warn, error. (default "warn")
  -server string
    	Backend server host and port. (default "motki.org:18443")
  -version
    	Display the application version.

Authenticating

Some functionality in the application requires authenticating with the remote motkid installation (by default, the Moritake Industries website).

To authenticate:

  1. Ensure you have a valid account with characters linked on the remote motkid installation.

  2. Configure motki to use your credentials.

    1. Pass them via command-line option:
    motki -credentials username:password
    
    1. Pass them via environment variables:
    MOTKI_USERNAME=username MOTKI_PASSWORD=password motki
    

Building

The recommended way to build this project is using make, though it is compatible with go get and friends.

Prerequisites:

  1. A semi-recent version of git.
  2. A valid go toolchain install and environment configuration.
Building with make
  1. Clone or download and extract the source code and place it in the proper place inside your $GOPATH.

    mkdir -p $GOPATH/src/github.com/motki
    git clone https://github.com/motki/cli $GOPATH/src/github.com/motki/cli
    cd $GOPATH/src/github.com/motki/cli
    
  2. Use the included Makefile to build the application.

    cd $GOPATH/src/github.com/motki/cli
    make build
    
Cross-compiling the application

Each build target supports specifying GOOS and GOARCH to facilitate cross-compiling. For example, building the MOTKI CLI for 32-bit ARM linux:

make build GOOS="linux" GOARCH="arm"

See the Go language documentation for more information on supported OSes and architectures.

Build the motki program for a combination of OSes and architectures with make matrix. Use OSES and ARCHES to configure which platforms to target.

make matrix OSES="windows linux darwin" ARCHES="amd64 x86"
Building with go

Download and install motki and its dependencies using go get.

go get -u github.com/motki/cli/...

After go get exits successfully, you should have a new command in your $GOBIN called motki.

cd $GOPATH/src/github.com/motki/cli
go build ./cmd/motki/*.go

Documentation

Overview

Package cli is a command-line interface and supporting libraries for interacting with a remote MOTKI application server.

This project contains the motki command source code, as well text-processing functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticated() bool
}

Authenticator is implemented by a type that is responsible for authentication.

type Command

type Command interface {
	// Description returns a ~40 character sentence describing the command.
	Description() string

	// Prefixes defines the names that the command will be invoked under.
	//
	// This is a slice to allow for alternatives and shorthands to be considered
	// as a prefix for the command.
	Prefixes() []string

	// Handle executes the given subcmd, if any, with the given arguments.
	Handle(subcmd string, args ...string)

	// PrintHelp prints a helpful overview describing the Command its subcommands.
	PrintHelp()
}

A Command is a single command that a Server supports.

Commands display description and help information. Each Command may support any number of sub-commands, all of which receive further arguments in a byte slice.

Commands are registered with a Server before beginning the Server's loop.

type Prompter

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

A Prompter handles prompting the user for well-defined input.

func NewPrompter

func NewPrompter(cli *Server, cl client.Client, logger log.Logger) *Prompter

func (*Prompter) Prompt

func (p *Prompter) Prompt(prompt string) (string, error)

Prompt displays the prompt and returns the string input.

func (*Prompter) PromptDecimal

func (p *Prompter) PromptDecimal(prompt string, defVal *decimal.Decimal, filters ...func(decimal.Decimal) (decimal.Decimal, bool)) (decimal.Decimal, bool)

PromptDecimal prompts the user for a valid decimal input.

If defVal is not nil, the prompt will be pre-populated with the default value.

Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.

func (*Prompter) PromptInt

func (p *Prompter) PromptInt(prompt string, defVal *int, filters ...func(int) (int, bool)) (int, bool)

PromptInt prompts the user for a valid integer input.

If defVal is not nil, the prompt will be pre-populated with the default value.

Additionally, any number of filter functions can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.

func (*Prompter) PromptItemTypeDetail

func (p *Prompter) PromptItemTypeDetail(prompt string, initialInput string) (*evedb.ItemTypeDetail, bool)

PromptItemTypeDetail prompts the user for a valid item type input.

If the user enters an integer, it is treated as the item's Type ID. Otherwise, the value is used to lookup item types.

This function also accepts an initial input that should be used to as the first round of prompt input.

func (*Prompter) PromptRegion

func (p *Prompter) PromptRegion(prompt string, initialInput string) (*evedb.Region, bool)

PromptRegion prompts the user for a valid region input.

If the user enters an integer, it is treated as the region's Region ID. Otherwise, the value is used to lookup regions.

This function also accepts an initial input that should be used to as the first round of prompt input.

func (*Prompter) PromptString

func (p *Prompter) PromptString(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, bool)

PromptString prompts the user for any string input.

If defVal is not nil, the prompt will be pre-populated with the default value.

Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.

func (*Prompter) PromptStringWithArgs

func (p *Prompter) PromptStringWithArgs(prompt string, defVal *string, filters ...func(string) (string, bool)) (string, []string, bool)

PromptStringWithArgs prompts the user for any string input.

This function differs from PromptString in that it will split the received input by spaces, returning the first value as the main value, and a slice of additional arguments.

If defVal is not nil, the prompt will be pre-populated with the default value.

Additionally, any number of filter funcs can be passed in to perform custom validation and filtering on the user's input. Filter functions receive the value received from the prompt and return the new value and and indicator whether the value is valid.

func (*Prompter) PromptWithSuggestion

func (p *Prompter) PromptWithSuggestion(prompt string, text string, pos int) (string, error)

PromptWithSuggestion displays prompt and an editable text with cursor at given position.

type Server

type Server struct {
	*liner.State
	// contains filtered or unexported fields
}

A Server handles command-line requests and prints responses to standard output.

func NewServer

func NewServer(logger log.Logger, a Authenticator) *Server

NewServer initializes a new CLI server.

func (*Server) LoopCLI

func (srv *Server) LoopCLI()

LoopCLI starts an endless loop to perform commands read from stdin.

func (*Server) PrintHelp

func (srv *Server) PrintHelp()

PrintHelp prints the application-level help text.

func (*Server) SetCommands

func (srv *Server) SetCommands(commands ...Command)

Directories

Path Synopsis
Package app contains functionality related to creating an interactive command-line interface environment with all the necessary dependencies.
Package app contains functionality related to creating an interactive command-line interface environment with all the necessary dependencies.
cmd
motki
Command motki is a utility for interacting with a remote MOTKI application server.
Command motki is a utility for interacting with a remote MOTKI application server.
Package command contains the implementations for subcommands supported by the motki command.
Package command contains the implementations for subcommands supported by the motki command.
Package editor is an interactive command-line editor that supports sub-commands with arguments.
Package editor is an interactive command-line editor that supports sub-commands with arguments.
Package text contains functions for formatting console text.
Package text contains functions for formatting console text.
banner
Package banner is a dynamic ASCII art banner generator.
Package banner is a dynamic ASCII art banner generator.

Jump to

Keyboard shortcuts

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