Documentation
¶
Index ¶
Constants ¶
const ( BuiltinScriptPath = "<built-in>" BuiltinAuthor = "<built-in>" BuiltinVersion = "<built-in>" )
Constants for built-in commands.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { Close() error Init() ScriptPath() string Verb() string Help() string Usage() string Author() string Version() string Run(ctx context.Context, arg []string) error }
Command is an individual subcommand.
type Router ¶
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 ¶
func NewRouter(opts ...RouterOption) (*Router, error)
NewRouter creates a new instance of Router and sets it up for use.
func (*Router) AddCommand ¶
AddCommand adds a given command instance to the eclier router.
type RouterOption ¶
type RouterOption func(*Router)
RouterOption is a functional option for Router.
func WithAsarFile ¶
func WithAsarFile(shortName, fname string) RouterOption
WithAsarFile loads an asar file full of lua scripts into this eclier router.
func WithFilesystem ¶
func WithFilesystem(shortName string, fs http.FileSystem) RouterOption
WithFilesystem loads a http.FileSystem full of lua scripts into this eclier router.
func WithGluaCreationHook ¶
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 ¶
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.