On Sat, Oct 16, 2010 at 4:58 PM, Alexander Gladysh <[email protected]> wrote:
> Since everything is already there, I guess the implementation should
> be a three-liner.
For the curious, this is how you can add your own tools.
First, create a driver that works like the main luarocks one
-- lr-tools
#!/usr/bin/env lua
local command_line = require("luarocks.command_line")
program_name = "luarocks-tools"
program_description = "luarocks-tools main command-line interface"
commands = {}
commands.check_rockspec = require 'check_rockspec'
commands.help = require 'luarocks.help'
command_line.run_command(...)
------------------------------------------------------
-- check_rockspec.lua (must be on Lua module path obviously!)
local fetch = require 'luarocks.fetch'
local util = require 'luarocks.util'
module 'check_rockspec'
help_summary = "verify a rockspec."
help_arguments = "rockspec"
help = [[
The single argument must be a path to a local rockspec.
]]
function run(...)
local flags,arg = util.parse_flags(...)
if not arg then return nil,"please provide a rockspec" end
local ok,err = fetch.load_local_rockspec (arg)
if not ok then
return nil,err
end
return true
end
----------------------------------------------------
$ ./lr-tools check_rockspec fake-1.1-1.rockspec
then does exactly what you want.
Now, there is a reason for this machinery - the main command_lines
module does a fair amount of setting-up the environment. So we do need
all this to run the single function load_local_rockspec that actually
does all the work...
steve d.
_______________________________________________
Luarocks-developers mailing list
[email protected]
http://lists.luaforge.net/cgi-bin/mailman/listinfo/luarocks-developers