summaryrefslogtreecommitdiff
path: root/xmake/plugins/format
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-02 00:58:03 +0800
committerruki <[email protected]>2023-02-02 00:58:03 +0800
commit1a14178101b25cddbdee751f382b7bd9a5b15088 (patch)
treef4641c1000e938901f2e9094a7d7411f8ff247ea /xmake/plugins/format
parentb128cb98313b95b65f1d5bd2028831861ca80e13 (diff)
fix xmake format
Diffstat (limited to 'xmake/plugins/format')
-rw-r--r--xmake/plugins/format/main.lua7
-rw-r--r--xmake/plugins/format/xmake.lua11
2 files changed, 10 insertions, 8 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 9a119aec3..328bcb394 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -73,10 +73,9 @@ function main()
-- set file to format
if option.get("files") then
- -- list of files/path to format
- local files = option.get("file"):split(" ")
+ local files = path.splitenv(option.get("files"))
for _, f in ipairs(files) do
- local p = path.join(project, f)
+ local p = path.join(projectdir, f)
for _, filepath in ipairs(os.files(p)) do
table.insert(argv, filepath)
end
@@ -97,7 +96,7 @@ function main()
-- format files
os.vrunv(clang_format.program, argv, {curdir = projectdir})
- cprint("${color.success}formatting complete")
+ cprint("${color.success}format ok!")
-- done
os.setenvs(oldenvs)
diff --git a/xmake/plugins/format/xmake.lua b/xmake/plugins/format/xmake.lua
index d3a00039f..ed2bf3d65 100644
--- a/xmake/plugins/format/xmake.lua
+++ b/xmake/plugins/format/xmake.lua
@@ -25,10 +25,13 @@ task("format")
usage = "xmake format [options] [arguments]",
description = "Format the current project.",
options = {
- {'s', "style", "kv", nil, "Set the path of .clang-format file, a coding style"..
- "(LLVM, Google, Chromium, Mozilla, WebKit) or key value string" },
- {nil, "create", "k", nil, "Create a .clang-format file from a coding style" },
- {'f', "files", "v", nil, "Set file path or glob pattern"}
+ {'s', "style", "kv", nil, "Set the path of .clang-format file, a coding style",
+ values = {"LLVM", "Google", "Chromium", "Mozilla", "WebKit"}},
+ {nil, "create", "k", nil, "Create a .clang-format file from a coding style"},
+ {'f', "files", "v", nil, "Set files path with pattern",
+ "e.g.",
+ " - xmake format -f src/main.c",
+ " - xmake format -f 'src/*.c" .. path.envsep() .. "src/**.cpp'"}
}
}