summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-06-01 08:16:54 +0800
committerruki <[email protected]>2016-06-01 08:16:54 +0800
commite720bbe224eb7aec57ca488a67e840a685fe612f (patch)
tree2735ac6524ec7ca93f7508eadfdfc3241ee08f0c
parent5b2e0333389158094a2a8bb796e13f99fac422e7 (diff)
list lua scripts and fix arguments
-rw-r--r--xmake/core/base/option.lua4
-rw-r--r--xmake/core/sandbox/modules/os.lua16
-rwxr-xr-xxmake/plugins/doxygen/xmake.lua2
-rwxr-xr-xxmake/plugins/lua/xmake.lua15
-rwxr-xr-xxmake/plugins/macro/main.lua2
-rwxr-xr-xxmake/plugins/macro/xmake.lua50
-rwxr-xr-xxmake/plugins/project/main.lua1
7 files changed, 59 insertions, 31 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index eb9af790e..7deb2a3f4 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -724,13 +724,15 @@ function option.show_options(options)
if name then
if mode == "v" then
option_info = option_info .. " " .. name
+ elseif mode == "vs" then
+ option_info = option_info .. " " .. name .. " ..."
else
option_info = option_info .. option._ifelse(shortname, ", --", " --") .. name
end
if mode == "kv" then
option_info = option_info .. "=" .. name:upper()
end
- elseif mode == "v" then
+ elseif mode == "v" or mode == "vs" then
option_info = option_info .. " ..."
end
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 923cc5852..9babc4318 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -24,6 +24,7 @@
local io = require("base/io")
local os = require("base/os")
local utils = require("base/utils")
+local sandbox = require("sandbox/sandbox")
local vformat = require("sandbox/modules/vformat")
-- define module
@@ -174,6 +175,21 @@ function sandbox_os.programdir()
return xmake._PROGRAM_DIR
end
+-- get the script directory
+function sandbox_os.scriptdir()
+
+ -- get the current sandbox instance
+ local instance = sandbox.instance()
+ assert(instance)
+
+ -- the root directory for this sandbox script
+ local rootdir = instance:rootdir()
+ assert(rootdir)
+
+ -- ok
+ return rootdir
+end
+
-- run shell
function sandbox_os.run(cmd, ...)
diff --git a/xmake/plugins/doxygen/xmake.lua b/xmake/plugins/doxygen/xmake.lua
index 081ed7034..4bead9547 100755
--- a/xmake/plugins/doxygen/xmake.lua
+++ b/xmake/plugins/doxygen/xmake.lua
@@ -32,7 +32,7 @@ task("doxygen")
usage = "xmake doxygen [options] [name] [arguments]"
-- description
- , description = "Generate the doxygen document for the given name"
+ , description = "Generate the doxygen document for the given name."
-- options
, options =
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index 5473a3b55..519a06d1d 100755
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -32,6 +32,16 @@ task("lua")
-- imports
import("core.base.option")
+ -- list all scripts?
+ print("scripts:")
+ if option.get("list") then
+ local files = os.match(path.join(os.scriptdir(), "scripts/*.lua"))
+ for _, file in ipairs(files) do
+ print(" " .. path.basename(file))
+ end
+ return
+ end
+
-- get script name
local name = option.get("script")
if not name then
@@ -57,8 +67,9 @@ task("lua")
-- options
, options =
{
- {nil, "script", "v", nil, "Run the given lua script." }
- , {nil, "arguments", "vs", nil, "The script arguments" }
+ {'l', "list", "k", nil, "List all scripts." }
+ , {nil, "script", "v", nil, "Run the given lua script." }
+ , {nil, "arguments", "vs", nil, "The script arguments." }
}
})
diff --git a/xmake/plugins/macro/main.lua b/xmake/plugins/macro/main.lua
index 89c6e1f54..3de5ca598 100755
--- a/xmake/plugins/macro/main.lua
+++ b/xmake/plugins/macro/main.lua
@@ -201,7 +201,7 @@ function _run(macroname)
macro = import(macroname, {rootdir = _directory()})
-- run macro
- macro.main((option.get("argv") or ""):split("%s"))
+ macro.main(option.get("arguments"))
-- trace
print("run macro(%s) ok!", macroname)
diff --git a/xmake/plugins/macro/xmake.lua b/xmake/plugins/macro/xmake.lua
index dc4f9ca1a..f28c5b49f 100755
--- a/xmake/plugins/macro/xmake.lua
+++ b/xmake/plugins/macro/xmake.lua
@@ -35,7 +35,7 @@ task("macro")
usage = "xmake macro|m [options] [name] [arguments]"
-- description
- , description = "Run the given macro"
+ , description = "Run the given macro."
-- xmake m
, shortname = 'm'
@@ -43,32 +43,32 @@ task("macro")
-- options
, options =
{
- {'b', "begin", "k", nil, "Start to record macro."
- , ".e.g"
- , "Record macro with name: test"
- , " xmake macro --begin"
- , " xmake config --plat=macosx"
- , " xmake clean"
- , " xmake -r"
- , " xmake package"
- , " xmake macro --end test" }
- , {'e', "end", "k", nil, "Stop to record macro." }
+ {'b', "begin", "k", nil, "Start to record macro."
+ , ".e.g"
+ , "Record macro with name: test"
+ , " xmake macro --begin"
+ , " xmake config --plat=macosx"
+ , " xmake clean"
+ , " xmake -r"
+ , " xmake package"
+ , " xmake macro --end test" }
+ , {'e', "end", "k", nil, "Stop to record macro." }
, {}
- , {nil, "show", "k", nil, "Show the content of the given macro." }
- , {'l', "list", "k", nil, "List all macros." }
- , {'d', "delete", "k", nil, "Delete the given macro." }
+ , {nil, "show", "k", nil, "Show the content of the given macro." }
+ , {'l', "list", "k", nil, "List all macros." }
+ , {'d', "delete", "k", nil, "Delete the given macro." }
, {}
- , {nil, "import", "kv", nil, "Import the given macro file."
- , ".e.g"
- , " xmake macro --import=/xxx/macro.lua test" }
- , {nil, "export", "kv", nil, "Export the given macro to file."
- , ".e.g"
- , " xmake macro --export=/xxx/macro.lua test" }
+ , {nil, "import", "kv", nil, "Import the given macro file."
+ , ".e.g"
+ , " xmake macro --import=/xxx/macro.lua test" }
+ , {nil, "export", "kv", nil, "Export the given macro to file."
+ , ".e.g"
+ , " xmake macro --export=/xxx/macro.lua test" }
, {}
- , {'a', "argv", "kv", nil, "Set the macro arguments." }
- , {nil, "name", "v", ".", "The given macro name."
- , ".e.g"
- , " Run the given macro: xmake macro test"
- , " Run the anonymous macro: xmake macro ." }
+ , {nil, "name", "v", ".", "Set the macro name."
+ , ".e.g"
+ , " Run the given macro: xmake macro test"
+ , " Run the anonymous macro: xmake macro ." }
+ , {nil, "arguments", "vs", nil, "Set the macro arguments." }
}
})
diff --git a/xmake/plugins/project/main.lua b/xmake/plugins/project/main.lua
index 7d5362c9f..fc8b63ec8 100755
--- a/xmake/plugins/project/main.lua
+++ b/xmake/plugins/project/main.lua
@@ -71,5 +71,4 @@ function main()
-- trace
print("create ok!")
-
end