extensions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 21 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')",
	},

	{
		"task",
		"Checks if the given task is up to date and if not, executes the given task. This is useful for incremental builds.",
		[]string{"src any", "out any", "tool function|table"},
		[]string{"true if the toolchain was executed, false otherwise."},
		task.Task,
		"boolean",
		"yab.task(\n" +
			"\t{'foo.c'},\n" +
			"\t{'foo.o'},\n" +
			"\tfunction()\n" +
			"\t\tos.execute('gcc -c foo.c -o foo.o')\n" +
			"end)",
	},

	{
		"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",
		"",
	},

	{
		"cd",
		"Changes the current working directory to the given path for one function call.",
		[]string{"path string", "fn function"},
		[]string{},
		cd.Cd,
		"",
		"",
	},

	{
		"mkdir",
		"Creates a new directory.",
		[]string{"path string"},
		[]string{},
		mkdir.Mkdir,
		"",
		"yab.mkdir('foo')",
	},

	{
		"rm",
		"Removes a file or directory.",
		[]string{"path string"},
		[]string{},
		rm.Rm,
		"",
		"yab.rm(\"./foo/bar\")",
	},
	{
		"rm",
		"Removes a file or directory.",
		[]string{"path string", "recursive boolean"},
		[]string{},
		rm.Rm,
		"",
		"yab.rm(\"./foo/bar\", true)",
	},

	{
		"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",
		"",
	},

	{
		"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)",
	},

	{
		"download",
		"Download a file from the internet.",
		[]string{"url string"},
		[]string{"The name of the downloaded file."},
		download.Download,
		"string",
		"yab.download('https://example.com/foo.txt')",
	},
	{
		"download",
		"Download a file from the internet to a specified destination.",
		[]string{"url string", "destination string"},
		[]string{"The name of the downloaded file."},
		download.Download,
		"string",
		"yab.download('https://example.com/foo.txt', 'foo.txt')",
	},

	{
		"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)",
	},

	{
		"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