From 496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 18 Sep 2012 20:55:57 -0300 Subject: Add 'lint' command, to check for rockspec validity. --- src/bin/luarocks | 1 + src/luarocks/lint.lua | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/luarocks/lint.lua (limited to 'src') diff --git a/src/bin/luarocks b/src/bin/luarocks index 1397bbd0..e94d895f 100755 --- a/src/bin/luarocks +++ b/src/bin/luarocks @@ -19,5 +19,6 @@ commands.download = require("luarocks.download") commands.path = require("luarocks.path") commands.show = require("luarocks.show") commands.new_version = require("luarocks.new_version") +commands.lint = require("luarocks.lint") command_line.run_command(...) diff --git a/src/luarocks/lint.lua b/src/luarocks/lint.lua new file mode 100644 index 00000000..63b549aa --- /dev/null +++ b/src/luarocks/lint.lua @@ -0,0 +1,37 @@ + +--- Module implementing the LuaRocks "lint" command. +-- Utility function that checks syntax of the rockspec. +module("luarocks.lint", package.seeall) + +local util = require("luarocks.util") +local download = require("luarocks.download") +local fetch = require("luarocks.fetch") + +help_summary = "Check syntax of a rockspec." +help_arguments = "" +help = [[ +This is a utility function that checks the syntax of a rockspec. + +It reports success or failure if the text of a rockspec is +syntactically correct. +]] + +function run(...) + local flags, input = util.parse_flags(...) + + local filename = input + if not input:match(".rockspec$") then + local err + filename, err = download.download("rockspec", input) + if not filename then + return nil, err + end + end + + local rs, err = fetch.load_local_rockspec(filename) + if not rs then + return nil, "Failed loading rockspec: "..err + end + + return true +end -- cgit v1.2.3-55-g6feb