diff options
| author | ruki <[email protected]> | 2016-02-26 22:36:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-02-26 22:36:49 +0800 |
| commit | 4e56f11cf31ad1279505ee5ed7e29945c20f0639 (patch) | |
| tree | f47e21c69a5d7b82e9d6105f28a2086542ad5d70 | |
| parent | 5520585557e76e13368325c50ffb0ca344f2c714 (diff) | |
add ifelse builtin interface for sandbox
| -rw-r--r-- | xmake/core/action/create.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/template.lua | 4 | ||||
| -rw-r--r-- | xmake/core/sandbox/ifelse.lua | 25 | ||||
| -rw-r--r-- | xmake/core/sandbox/import/template.lua | 6 | ||||
| -rwxr-xr-x | xmake/core/tasks/create.lua | 5 |
5 files changed, 33 insertions, 9 deletions
diff --git a/xmake/core/action/create.lua b/xmake/core/action/create.lua index 30a811b12..cf6dbcd71 100644 --- a/xmake/core/action/create.lua +++ b/xmake/core/action/create.lua @@ -97,7 +97,7 @@ function action_create.menu() local languages = template.languages() for _, language in ipairs(languages) do table.insert(descriptions, string.format(" - language: %s", language)) - local templates = template.loadall(language) + local templates = template.templates(language) if templates then for i, template in ipairs(templates) do table.insert(descriptions, string.format(" %d. %s", i, utils.ifelse(template.description, template.description, "The Unknown Project"))) diff --git a/xmake/core/base/template.lua b/xmake/core/base/template.lua index 08b997a87..76f5398c5 100644 --- a/xmake/core/base/template.lua +++ b/xmake/core/base/template.lua @@ -111,7 +111,7 @@ function template.languages() end -- load all templates from the given language -function template.loadall(language) +function template.templates(language) -- check assert(language) @@ -194,7 +194,7 @@ function template.create(language, templateid, targetname) end)) -- load all templates for the given language - local templates = template.loadall(language) + local templates = template.templates(language) -- load the template module local module = nil diff --git a/xmake/core/sandbox/ifelse.lua b/xmake/core/sandbox/ifelse.lua new file mode 100644 index 000000000..bbd032704 --- /dev/null +++ b/xmake/core/sandbox/ifelse.lua @@ -0,0 +1,25 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file ifelse.lua +-- + +-- load module +return require("sandbox/utils").ifelse + diff --git a/xmake/core/sandbox/import/template.lua b/xmake/core/sandbox/import/template.lua index 712d01b25..980e98a52 100644 --- a/xmake/core/sandbox/import/template.lua +++ b/xmake/core/sandbox/import/template.lua @@ -1,4 +1,4 @@ ---!The Automatic Cross-template Build Tool +--!The Automatic Cross-platform Build Tool -- -- XMake is free software; you can redistribute it and/or modify -- it under the terms of the GNU Lesser General Public License as published by @@ -38,10 +38,10 @@ function sandbox_template.languages() end -- load all templates from the given language -function sandbox_template.loadall(language) +function sandbox_template.templates(language) -- get it - local templates = template.loadall(language) + local templates = template.templates(language) assert(templates) -- ok diff --git a/xmake/core/tasks/create.lua b/xmake/core/tasks/create.lua index d8fc13a2c..9df66ae7d 100755 --- a/xmake/core/tasks/create.lua +++ b/xmake/core/tasks/create.lua @@ -67,8 +67,8 @@ task("create") local description = {} for _, language in ipairs(template.languages()) do table.insert(description, format(" - language: %s", language)) - for i, t in ipairs(template.loadall(language)) do - table.insert(description, format(" %d. %s", i, utils.ifelse(t.description, t.description, "The Unknown Project"))) + for i, t in ipairs(template.templates(language)) do + table.insert(description, format(" %d. %s", i, ifelse(t.description, t.description, "The Unknown Project"))) end end @@ -77,7 +77,6 @@ task("create") end } , {} - , {} , {nil, "target", "v", nil, "Create the given target." , "Uses the project name as target if not exists." } } |
