extensions

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Functions = []Function{
	{
		"use",
		"Makes the specified package available for use in the script. " +
			"Currently supported packages are: " +
			strings.Join(use.Usable, ", ") + ".",
		[]string{
			"package '" + strings.Join(use.Usable, "'|'") + "'",
			"version string"},
		[]string{},
		use.Use,
		"",
		"Yab.use('golang', '1.21.6')\n" +
			"Yab.use('nodejs', '14.17.6')",
	},
	{
		"tool",
		"Checks if the given toolchain is up to date and if not, executes the given toolchain.",
		[]string{"in any", "out any", "tool function|table"},
		[]string{"true if the toolchain was executed, false otherwise."},
		tool.Tool,
		"boolean",
		"Yab.tool(\n" +
			"\t{'foo.c'},\n" +
			"\t{'foo.o'},\n" +
			"\tfunction()\n" +
			"\t\tos.execute('gcc -c foo.c -o foo.o')\n" +
			"\tend)",
	},
	{
		"os_type",
		"Returns the operating system type.",
		[]string{},
		[]string{"\"windows\", \"linux\" or \"darwin\" on the respective system."},
		ostype.OsType,
		"'windows'|'linux'|'darwin'",
		"",
	},
	{
		"os_arch",
		"Returns the operating system architecture.",
		[]string{},
		[]string{"\"amd64\" or \"arm64\" on the respective system."},
		osarch.OsArch,
		"'amd64'|'arm64'",
		"",
	},
	{
		"args",
		"Returns the command line arguments passed to the program.",
		[]string{},
		[]string{"A table containing the command line arguments."},
		args.Args,
		"table",
		"",
	},
	{
		"check_exec",
		"Checks if an executable is available in the system's PATH.",
		[]string{"executable string"},
		[]string{"true if the executable is available, false otherwise."},
		checkexec.CheckExec,
		"boolean",
		"",
	},
	{
		"stdall",
		"Call a shell command and return the full output (stdout + stderr) in one string.",
		[]string{"command string"},
		[]string{"The output of the command."},
		std.All,
		"string",
		"",
	},
	{
		"stdout",
		"Call a shell command and return the output (stdout) in one string.",
		[]string{"command string"},
		[]string{"The output of the command."},
		std.Out,
		"string",
		"",
	},
	{
		"stderr",
		"Call a shell command and return the error output (stderr) in one string.",
		[]string{"command string"},
		[]string{"The output of the command."},
		std.Err,
		"string",
		"",
	},
	{
		"js_run",
		"Run a script from the `package.json` file using the first javascript package manager found. Trying pnpm, bun and npm in that order.",
		[]string{"script string"},
		[]string{},
		javascript.JsRun,
		"",
		"",
	},
	{
		"js_install",
		"Install dependencies from `package.json` using the first javascript package manager found. Trying pnpm, bun and npm in that order.",
		[]string{},
		[]string{},
		javascript.JsInstall,
		"",
		"",
	},
	{
		"git_clone_or_pull",
		"Clones a git repository to a specified destination. If the repository already exists, it will pull the latest changes instead.",
		[]string{"url string", "destination string"},
		[]string{},
		git.GitCloneOrPull,
		"",
		"",
	},
	{
		"zip",
		"Create a zip file containing the given files.",
		[]string{"files table", "output string"},
		[]string{},
		zip.MakeZip,
		"",
		"Yab.zip(\n\t{'foo.txt', 'bar.txt', 'baz/'},\n\t'archive.zip'\n)",
	},
	{
		"watch",
		"Watch file or directory paths for changes and call a function when a change occurs. " +
			"The callback function will be called with the file path and the event type as arguments. " +
			"The event type can be one of 'create', 'write', 'remove', 'rename' or 'chmod'.",
		[]string{"paths table", "callback function(string, string)"},
		[]string{},
		watch.Watch,
		"",
		"Yab.watch('foo.txt', function(file, event)\n\tprint('foo.txt changed!')\nend)",
	},
	{
		"block",
		"Block the current thread and wait for an interrupt signal.",
		[]string{},
		[]string{},
		block.Block,
		"",
		"Yab.block()",
	},
	{
		"find",
		"Find files matching a pattern in a directory.",
		[]string{"pattern string"},
		[]string{"A table containing the matching file paths."},
		find.Find,
		"table",
		"Yab.find('*.txt')",
	},
	{
		"find",
		"Find files matching a pattern in a directory.",
		[]string{"root string", "pattern string"},
		[]string{"A table containing the matching file paths."},
		find.Find,
		"table",
		"Yab.find('foo', '*.txt')",
	},
	{
		"fileinfo",
		"Get information about a file.",
		[]string{"path string"},
		[]string{"A table containing the file information (name, size, mode, modtime, isdir, sys). See https://pkg.go.dev/io/fs#FileInfo for details."},
		fileinfo.FileInfo,
		"table",
		"local foo_info = Yab.fileinfo('foo.txt')\nprint(foo_info.size)",
	},
	{
		"checked_run",
		"checks if a program is available in the system's PATH and then runs the specified command.",
		[]string{"packages table"},
		[]string{},
		checkedrun.Checkedrun,
		"",
		`Yab.checked_run({
    apt = "sudo apt install libsdl2{,-image,-mixer,-ttf,-gfx}-dev",
    dnf = "sudo dnf install SDL2{,_image,_mixer,_ttf,_gfx}-devel",
    pacman = "sudo pacman -S sdl2{,_image,_mixer,_ttf,_gfx}",
    emerge = "emerge -av libsdl2 sdl2-{image,mixer,ttf,gfx}",
    brew = "brew install sdl2{,_image,_mixer,_ttf,_gfx} pkg-config",
    vcpkg = "vcpkg install --triplet x64-windows sdl2 sdl2-image sdl2-mixer sdl2-ttf sdl2-gfx --recurse",
})`,
	},
	{
		"checked_run",
		"checks if a program is available in the system's PATH and then runs the specified command.",
		[]string{"packages table", "continueAfterFirst boolean"},
		[]string{},
		checkedrun.Checkedrun,
		"",
		`Yab.checked_run({
    apt = "sudo apt install libsdl2{,-image,-mixer,-ttf,-gfx}-dev",
    dnf = "sudo dnf install SDL2{,_image,_mixer,_ttf,_gfx}-devel",
    pacman = "sudo pacman -S sdl2{,_image,_mixer,_ttf,_gfx}",
    emerge = "emerge -av libsdl2 sdl2-{image,mixer,ttf,gfx}",
    brew = "brew install sdl2{,_image,_mixer,_ttf,_gfx} pkg-config",
    vcpkg = "vcpkg install --triplet x64-windows sdl2 sdl2-image sdl2-mixer sdl2-ttf sdl2-gfx --recurse",
}, false)`,
	},
	{
		"pretty",
		"Pretty print a table.",
		[]string{"value any"},
		[]string{"A string representation of the table."},
		pretty.Pretty,
		"string",
		"Yab.pretty({foo = 'bar', baz = 'qux'})",
	},
	{
		"print",
		"Pretty print a table.",
		[]string{"value any"},
		[]string{},
		pretty.PrintPretty,
		"",
		"Yab.print({foo = 'bar', baz = 'qux'})",
	},
}

Functions

func Definitions

func Definitions() string

func RegisterExtensions

func RegisterExtensions(l *lua.LState)

Types

type Function

type Function struct {
	Name        string
	Description string
	Parameters  []string
	Returns     []string
	Function    func(l *lua.LState) int
	Ret         string
	Example     string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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