Module luarocks.search
Module implementing the LuaRocks "search" command. Queries LuaRocks servers.
Functions
act_on_src_or_rockspec (action, name, version, ...) | Given a name and optionally a version, try to find in the rocks servers a single .src.rock or .rockspec file that satisfies the request, and run the given function on it; or display to the user possibilities if it couldn't narrow down a single match. |
disk_search (repo, query, results) | Perform search on a local repository. |
find_suitable_rock (query) | Attempt to get a single URL for a given search. |
make_query (name, version) | Prepare a query in dependency table format. |
manifest_search (results, repo, query) | Perform search on a rocks server. |
match_name (query, name) | Test the name field of a query. |
pick_latest_version (name, versions) | Get the URL for the latest in a set of versions. |
print_results (results, show_repo, long) | Print a list of rocks/rockspecs on standard output. |
query_arch_as_table (query) | Convert the arch field of a query table to table format. |
run (..., name, version) | Driver function for "search" command. |
search_repos (query) | Search on all configured rocks servers. |
split_source_and_binary_results (results) | Splits a list of search results into two lists, one for "source" results to be used with the "build" command, and one for "binary" results to be used with the "install" command. |
store_if_match (results, repo, name, version, arch, query) | Store a match in a results table if version matches query. |
store_result (results, name, version, arch, repo) | Store a search result (a rock or rockspec) in the results table. |
Functions
- act_on_src_or_rockspec (action, name, version, ...)
-
Given a name and optionally a version, try to find in the rocks servers a single .src.rock or .rockspec file that satisfies the request, and run the given function on it; or display to the user possibilities if it couldn't narrow down a single match.
Parameters
- action: function: A function that takes a .src.rock or .rockspec URL as a parameter.
- name: string: A rock name
- version: string or nil: A version number may also be given.
- ...:
Return value:
The result of the action function, or nil and an error message. - disk_search (repo, query, results)
-
Perform search on a local repository.
Parameters
- repo: string: The pathname of the local repository.
- query: table: A table describing the query in dependency format (for example, {name = "filesystem", exact_name = false, constraints = {op = "~>", version = {1,0}}}, arch = "rockspec"). If the arch field is omitted, the local architecture (cfg.arch) is used. The special value "any" is also recognized, returning all matches regardless of architecture.
- results: table or nil: If given, this table will store the results; if not given, a new table will be created.
- find_suitable_rock (query)
-
Attempt to get a single URL for a given search.
Parameters
- query: table: A dependency query.
Return value:
string or table or (nil, string): URL for matching rock if a single one was found, a table of candidates if it could not narrow to a single result, or nil followed by an error message. - make_query (name, version)
-
Prepare a query in dependency table format.
Parameters
- name: string: The query name.
- version: string or nil:
Return value:
table: A query in table format - manifest_search (results, repo, query)
-
Perform search on a rocks server.
Parameters
- results: table: The results table, where keys are package names and versions are tables matching version strings to an array of servers.
- repo: string: The URL of the rocks server.
- query: table: A table describing the query in dependency format (for example, {name = "filesystem", exact_name = false, constraints = {op = "~>", version = {1,0}}}, arch = "rockspec"). If the arch field is omitted, the local architecture (cfg.arch) is used. The special value "any" is also recognized, returning all matches regardless of architecture.
Return value:
true or, in case of errors, nil and an error message. - match_name (query, name)
-
Test the name field of a query. If query has a boolean field exact_name set to false, then substring match is performed; otherwise, exact string comparison is done.
Parameters
- query: table: A query in dependency table format.
- name: string: A package name.
Return value:
boolean: True if names match, false otherwise. - pick_latest_version (name, versions)
-
Get the URL for the latest in a set of versions.
Parameters
- name: string: The package name to be used in the URL.
- versions: table: An array of version informations, as stored in search results tables.
Return value:
string or nil: the URL for the latest version if one could be picked, or nil. - print_results (results, show_repo, long)
-
Print a list of rocks/rockspecs on standard output.
Parameters
- results: table: A table where keys are package names and versions are tables matching version strings to an array of rocks servers.
- show_repo: boolean or nil: Whether to show repository
- long: boolean or nil: Whether to show module files information or not. Default is true.
- query_arch_as_table (query)
-
Convert the arch field of a query table to table format.
Parameters
- query: table: A query table.
- run (..., name, version)
-
Driver function for "search" command.
Parameters
- ...:
- name: string: A substring of a rock name to search.
- version: string or nil: a version may also be passed.
Return value:
boolean or (nil, string): True if build was successful; nil and an error message otherwise. - search_repos (query)
-
Search on all configured rocks servers.
Parameters
- query: table: A dependency query.
Return value:
table or (nil, string): A table where keys are package names and values are tables matching version strings to an array of rocks servers; if no results are found, an empty table is returned. In case of errors, nil and and error message are returned. - split_source_and_binary_results (results)
-
Splits a list of search results into two lists, one for "source" results to be used with the "build" command, and one for "binary" results to be used with the "install" command.
Parameters
- results: table: A search results table.
Return value:
(table, table): Two tables, one for source and one for binary results. - store_if_match (results, repo, name, version, arch, query)
-
Store a match in a results table if version matches query. Name, version, arch and repository path are stored in a given table, optionally checking if version and arch (if given) match a query.
Parameters
- results: table: The results table, where keys are package names and versions are tables matching version strings to an array of servers.
- repo: string: URL or pathname of the repository.
- name: string: The name of the package being tested.
- version: string: The version of the package being tested.
- arch: string: The arch of the package being tested.
- query: table: A table describing the query in dependency format (for example, {name = "filesystem", exact_name = false, constraints = {op = "~>", version = {1,0}}}, arch = "rockspec"). If the arch field is omitted, the local architecture (cfg.arch) is used. The special value "any" is also recognized, returning all matches regardless of architecture.
- store_result (results, name, version, arch, repo)
-
Store a search result (a rock or rockspec) in the results table.
Parameters
- results: table: The results table, where keys are package names and versions are tables matching version strings to an array of servers.
- name: string: Package name.
- version: string: Package version.
- arch: string: Architecture of rock ("all", "src" or platform identifier), "rockspec" or "installed"
- repo: string: Pathname of a local repository of URL of rocks server.