Module luarocks.api

A simple external API for LuaRocks.

This allows you to query the existing packages (show and list) and packages on a remote repository (search). Like the luarocks command-line tool, you can specify the flags from and only_from for this function.

Local information is a table: local_info_table. Usually you get less information for remote queries (basically, package, version and repo) but setting the flag details for search will fill in more fields by downloading the remote rockspecs - bear in mind that this can be slow for large queries.

It is also possible to install and remove packages. If you use the flag quiet, then normal output is suppressed and sent to a log file.

Functions

set_rocks_tree (make_local) set the current tree to be global or local
get_log_file () get the log file.
show (name, version, field) show information about an installed package.
list (pattern, version, flags) list information about currently installed packages.
list_map (pattern, version, flags) list information like list, but return as a map.
compare_versions (linfo, info) is this package outdated?.
search (pattern, version, flags) search LuaRocks repositories for a package.
search_map (pattern, version, flags) search repositories like search, but return a map.
install (name, version, flags) install a rock.
remove (name, version) remove a rock.

Tables

local_info_table information returned by show and list.
flags known flag names for the flags parameter.


Functions

set_rocks_tree (make_local)
set the current tree to be global or local

Parameters:

  • make_local: use the local tree (default false)
get_log_file ()
get the log file. This is used when the quiet flag is specified.

Returns:

    full path to log file
show (name, version, field)
show information about an installed package.

Parameters:

  • name: the package name
  • version: version, may be nil
  • field: one of the output fields

Returns:

    local_info_table, or a string if field is specified.

see also:

list (pattern, version, flags)
list information about currently installed packages.

Parameters:

  • pattern: a string which is partially matched against packages
  • version: a specific version, may be nil.
  • flags: flags

Returns:

    list of local_info_table
list_map (pattern, version, flags)
list information like list, but return as a map.

Parameters:

  • pattern: a string which is partially matched against packages
  • version: a specific version, may be nil.
  • flags: flags

Returns:

    a table where the keys are package names and values are local_info_table
compare_versions (linfo, info)
is this package outdated?. check.lua shows how to compare installed and available packages.

Parameters:

  • linfo: local info table
  • info: server info table

Returns:

    true if the package is out of date.
search (pattern, version, flags)
search LuaRocks repositories for a package.

Parameters:

  • pattern: a string which is partially matched against packages
  • version: a specific version, may be nil.
  • flags:

    flags a table with keys

    • 'all' means get all version information,
    • 'from' to add another repository to the search
    • 'only_from' to only search one repository
    • 'details' get more information about each package

Returns:

    a list of server information.

    • Without 'all', we get package, version and the remote server (repo)
    • With 'all', instead of the repo we get versions, which is a list of
      • version
      • repos
    • with 'details', you get pretty much what list returns. Note that this function will then have to download the remote rockspec for this, and may not always be able to deduce the modules provided by a package.

see also:

search_map (pattern, version, flags)
search repositories like search, but return a map.

Parameters:

  • pattern: a string which is partially matched against packages
  • version: a specific version, may be nil.
  • flags: flags

Returns:

    a table of server information indexed by package name.
install (name, version, flags)
install a rock.

Parameters:

  • name:
  • version: can ask for a specific version (default nil means get latest)
  • flags: flags use_local to install to local tree, from to add another repository to the search and only_from to only use the given repository

Returns:

  1. true if successful, nil if not.
  2. error message if not
remove (name, version)
remove a rock.

Parameters:

  • name:
  • version: a specific version (default nil means remove all)

Tables

local_info_table
information returned by show and list.

Fields:

  • package: canonical name
  • repo: the tree where found
  • version:
  • rock_dir: the full path to the rock
  • homepage:
  • maintainer:
  • license:
  • summary:
  • description:
  • build_type: (this is the rockspec's build.type)
  • modules: modules provided by this package
  • dependencies: packages that this package needs
flags
known flag names for the flags parameter.

Fields:

  • exact: (bool) query pattern is an exact name (default false)
  • use_local: use local rock tree, not global (default false)
  • from: include this URL in search
  • only_from: only use this URL in search
  • all: get all version info with search
  • quiet: suppress output to stdout, write it all to a log file. Can use get_log_file to find the name of the log.
generated by LDoc 0.5