diff options
| author | ruki <[email protected]> | 2015-05-03 14:02:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-03 14:03:10 +0800 |
| commit | 4a0ac3ab3b236df85fcad676a2570128a3363f07 (patch) | |
| tree | 8c9e53cb77198208963d439da2dbb2b9eb61a8a3 /xmake/scripts/base/main.lua | |
| parent | d5c1749a6f01d05cced27538798989c36b9d18f3 (diff) | |
parse command line and process help and version
Diffstat (limited to 'xmake/scripts/base/main.lua')
| -rw-r--r-- | xmake/scripts/base/main.lua | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/xmake/scripts/base/main.lua b/xmake/scripts/base/main.lua index 77a3110a5..e790dacda 100644 --- a/xmake/scripts/base/main.lua +++ b/xmake/scripts/base/main.lua @@ -31,7 +31,7 @@ local option = require("base/option") local menu = { -- title - title = "XMake " .. xmake._VERSION .. ", The Automatic Cross-platform Build Tool" + title = xmake._VERSION .. ", The Automatic Cross-platform Build Tool" -- copyright , copyright = "Copyright (C) 2015-2016 Ruki Wang, tboox.org\nCopyright (C) 2005-2014 Mike Pall, luajit.org" @@ -144,8 +144,8 @@ local menu = , {nil, "profile", "k", nil, "Compile for the profiling mode and disable the debugging mode."} , {} - , {nil, "output", "kv", "build", "Set the build output directory" } - , {nil, "packages", "kv", "pkg", "Set the packages directory" } + , {'o', "output", "kv", "build", "Set the build output directory" } + , {'k', "packages", "kv", "pkg", "Set the packages directory" } , {} , {nil, "cc", "kv", nil, "The c compiler" } @@ -255,14 +255,64 @@ local menu = } } +-- done option +function main.done_action() + + -- the options + local options = xmake._OPTIONS + assert(options) + + -- the action + local action = options._ACTION or "build" + + + -- ok + return true +end + +-- done option +function main.done_option() + + -- the options + local options = xmake._OPTIONS + assert(options) + + -- done help + if options.help then + option.print_menu(options._ACTION) + -- done version + elseif options.version then + -- print title + if option._MENU.title then + print(option._MENU.title) + end + + -- print copyright + if option._MENU.copyright then + print(option._MENU.copyright) + end + -- done action + else + return main.done_action() + end + + -- ok + return true +end + -- the main function function main.done() - -- done option first - if not option.done(xmake._ARGV, menu) then + -- init option first + if not option.init(xmake._ARGV, menu) then return -1 end - + + -- done option + if not main.done_option() then + return -1 + end + -- ok return 0 end |
