summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-13 21:06:35 +0800
committerruki <[email protected]>2021-12-13 21:06:35 +0800
commit08cf4155370bb59af849f0d4ad70aec1523f03fb (patch)
tree0377a0cc3f493efcee7d32259de1887627091794
parent2f53f461e013176fe45959690ec709737f487a64 (diff)
add -f/--force to xmake create
-rw-r--r--xmake/actions/create/main.lua4
-rw-r--r--xmake/actions/create/xmake.lua3
2 files changed, 4 insertions, 3 deletions
diff --git a/xmake/actions/create/main.lua b/xmake/actions/create/main.lua
index 611c0a57c..560b3b457 100644
--- a/xmake/actions/create/main.lua
+++ b/xmake/actions/create/main.lua
@@ -76,13 +76,13 @@ function _create_project(language, templateid, targetname)
end
-- xmake.lua exists?
- if os.isfile(path.join(projectdir, "xmake.lua")) then
+ if os.isfile(path.join(projectdir, "xmake.lua")) and not option.get("force") then
raise("project (${underline}%s/xmake.lua${reset}) exists!", projectdir)
end
-- empty project?
os.tryrm(path.join(projectdir, ".xmake"))
- if not os.emptydir(projectdir) then
+ if not os.emptydir(projectdir) and not option.get("force") then
-- otherwise, check whether it is empty
raise("project directory (${underline}%s${reset}) is not empty!", projectdir)
end
diff --git a/xmake/actions/create/xmake.lua b/xmake/actions/create/xmake.lua
index 005bdf6be..812411e03 100644
--- a/xmake/actions/create/xmake.lua
+++ b/xmake/actions/create/xmake.lua
@@ -38,7 +38,8 @@ task("create")
-- options
, options =
{
- {'l', "language", "kv", "c++", "The project language"
+ {'f', "force", "k", nil, "Force to create project in a non-empty directory."}
+ , {'l', "language", "kv", "c++", "The project language"
-- show the description of all languages
, values = function (complete, opt)