summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-10 08:45:22 +0800
committerruki <[email protected]>2017-05-10 08:45:22 +0800
commit1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a (patch)
tree369ae0ec06074ec28c944eaaca94e69db02a25b6
parentd80214fcfaa2f90b2ba6ec6991329d38901cff66 (diff)
improve doc for xmake lua pluginv2.1.4
-rw-r--r--docs/plugins.md64
-rwxr-xr-xdocs/zh/plugins.md72
2 files changed, 136 insertions, 0 deletions
diff --git a/docs/plugins.md b/docs/plugins.md
index 0c81b2fbc..8091f1456 100644
--- a/docs/plugins.md
+++ b/docs/plugins.md
@@ -338,6 +338,8 @@ end
#### Run the Custom Lua Script
+##### Run the given script
+
Write a simple lua script:
```lua
@@ -356,6 +358,68 @@ $ xmake lua /tmp/test.lua
You can also use `import` api to write a more advance lua script.
</p>
+##### Run the builtin script
+
+You can run `xmake lua -l` to list all builtin script name, for example:
+
+```bash
+$ xmake lua -l
+scripts:
+ cat
+ cp
+ echo
+ versioninfo
+ ...
+```
+
+And run them:
+
+```bash
+$ xmake lua cat ~/file.txt
+$ xmake lua echo "hello xmake"
+$ xmake lua cp /tmp/file /tmp/file2
+$ xmake lua versioninfo
+```
+
+##### Run interactive commands (REPL)
+
+Enter interactive mode:
+
+```bash
+$ xmake lua
+> 1 + 2
+3
+
+> a = 1
+> a
+1
+
+> for _, v in pairs({1, 2, 3}) do
+>> print(v)
+>> end
+1
+2
+3
+```
+
+And we can `import` modules:
+
+```bash
+> task = import("core.project.task")
+> task.run("hello")
+hello xmake!
+```
+
+If you want to cancel multiline input, please input character `q`, for example:
+
+```bash
+> for _, v in ipairs({1, 2}) do
+>> print(v)
+>> q <-- cancel multiline and clear previous input
+> 1 + 2
+3
+```
+
#### Generate IDE Project Files
##### Generate Makefile
diff --git a/docs/zh/plugins.md b/docs/zh/plugins.md
index 5d33e0dcc..2988fdb59 100755
--- a/docs/zh/plugins.md
+++ b/docs/zh/plugins.md
@@ -351,6 +351,8 @@ end
这个跟宏脚本类似,只是省去了导入导出操作,直接指定lua脚本来加载运行,这对于想要快速测试一些接口模块,验证自己的某些思路,都是一个不错的方式。
+##### 运行指定的脚本文件
+
我们先写个简单的lua脚本:
```lua
@@ -369,6 +371,76 @@ $ xmake lua /tmp/test.lua
当然,你也可以像宏脚本那样,使用`import`接口导入扩展模块,实现复杂的功能。
</p>
+##### 运行内置的脚本命令
+
+你可以运行 `xmake lua -l` 来列举所有内置的脚本名,例如:
+
+```bash
+$ xmake lua -l
+scripts:
+ cat
+ cp
+ echo
+ versioninfo
+ ...
+```
+
+并且运行它们:
+
+```bash
+$ xmake lua cat ~/file.txt
+$ xmake lua echo "hello xmake"
+$ xmake lua cp /tmp/file /tmp/file2
+$ xmake lua versioninfo
+```
+
+##### 运行交互命令 (REPL)
+
+有时候在交互模式下,运行命令更加的方便测试和验证一些模块和api,也更加的灵活,不需要再去额外写一个脚本文件来加载。
+
+我们先看下,如何进入交互模式:
+
+```bash
+# 不带任何参数执行,就可以进入
+$ xmake lua
+>
+
+# 进行表达式计算
+> 1 + 2
+3
+
+# 赋值和打印变量值
+> a = 1
+> a
+1
+
+# 多行输入和执行
+> for _, v in pairs({1, 2, 3}) do
+>> print(v)
+>> end
+1
+2
+3
+```
+
+我们也能够通过 `import` 来导入扩展模块:
+
+```bash
+> task = import("core.project.task")
+> task.run("hello")
+hello xmake!
+```
+
+如果要中途取消多行输入,只需要输入字符:`q` 就行了
+
+```bash
+> for _, v in ipairs({1, 2}) do
+>> print(v)
+>> q <-- 取消多行输入,清空先前的输入数据
+> 1 + 2
+3
+```
+
#### 生成IDE工程文件
##### 简介