eclier: Index | Files | Directories

package eclier

import ""


Package Files

builtin.go command.go router.go script.go


const (
    BuiltinScriptPath = "<built-in>"
    BuiltinAuthor     = "<built-in>"
    BuiltinVersion    = "<built-in>"

Constants for built-in commands.

type Command Uses

type Command interface {
    Close() error
    ScriptPath() string
    Verb() string
    Help() string
    Usage() string
    Author() string
    Version() string
    Run(ctx context.Context, arg []string) error

Command is an individual subcommand.

func NewBuiltinCommand Uses

func NewBuiltinCommand(verb, help, usage string, doer func(context.Context, []string) error) Command

NewBuiltinCommand makes it easier to write core commands for eclier.

type Router Uses

type Router struct {
    // contains filtered or unexported fields

Router is the main subcommand router for eclier. At a high level what this is doing is similar to http.ServeMux, but for CLI commands instead of HTTP handlers.

func NewRouter Uses

func NewRouter(opts ...RouterOption) (*Router, error)

NewRouter creates a new instance of Router and sets it up for use.

func (*Router) AddCommand Uses

func (r *Router) AddCommand(cmd Command)

AddCommand adds a given command instance to the eclier router.

func (*Router) Run Uses

func (r *Router) Run(ctx context.Context, arg []string) error

Run executes a single command given in slot 0 of the argument array.

type RouterOption Uses

type RouterOption func(*Router)

RouterOption is a functional option for Router.

func WithAsarFile Uses

func WithAsarFile(shortName, fname string) RouterOption

WithAsarFile loads an asar file full of lua scripts into this eclier router.

func WithFilesystem Uses

func WithFilesystem(shortName string, fs http.FileSystem) RouterOption

WithFilesystem loads a http.FileSystem full of lua scripts into this eclier router.

func WithGluaCreationHook Uses

func WithGluaCreationHook(hook func(*lua.LState)) RouterOption

WithGluaCreationHook adds a custom bit of code that runs every time a new gopher-lua LState is created. This allows users of this library to register custom libraries to the pile of states.

func WithScriptHome Uses

func WithScriptHome(dir string) RouterOption

WithScriptHome sets the router's script home to the given directory. This is where lua files will be walked and parsed.

type Script Uses

type Script struct {
    Verb    string
    Help    string
    Usage   string
    Author  string
    Version string



Package eclier imports 16 packages (graph). Updated 2019-06-09. Refresh now. Tools for package owners.