Skip to content

Commit f44257f

Browse files
authored
Merge pull request #382 from antfu/feat/cli
Cli for roman options
2 parents e18ccb9 + 385bc1d commit f44257f

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ npm install -g @wenyanlang/cli
7171
Try run the included examples, e.g.:
7272

7373
```bash
74-
wenyan examples/helloworld.wy -o helloworld.js
74+
wenyan examples/helloworld.wy
75+
# will outputs: 問天地好在。
7576
```
7677

78+
> From v0.1.0, the `wenyan` command will direct execute the script by default. If you are migrating from previous versions, please use `wenyan -h` to output the help and check [this PR](https://github.com/LingDong-/wenyan-lang) for the detailed changes.
79+
80+
7781
### [The Online IDE](http://wenyan-lang.lingdong.works/ide.html)
7882

7983
![](screenshots/screenshot02.png)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wenyanlang",
33
"description": "文言 A programming language for the ancient Chinese",
4-
"version": "0.0.2",
4+
"version": "0.1.0",
55
"author": "LingDong <[email protected]>",
66
"private": true,
77
"repository": {

src/cli.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ program
3434
"Output compiled code or executing result to file"
3535
)
3636
.option("-r, --render", "Outputs renderings")
37-
.option("--roman", "Romanize identifiers")
37+
.option(
38+
"--roman [method]",
39+
'Romanize identifiers. The method can be "pinyin", "baxter" or "unicode"'
40+
)
3841
.option("--log <file>", "Save log to file")
3942
.option("--title <title>", "Override title in rendering")
4043
.helpOption("-h, --help", "Display help");
@@ -91,11 +94,14 @@ function preprocess() {
9194
else if (program.render) program.output = `${base}.svg`;
9295
else program.output = `${base}.log`;
9396
}
97+
98+
if (program.roman == true) {
99+
program.roman = "pinyin";
100+
}
94101
}
95102

96103
function getCompiled() {
97104
const source = getSource();
98-
console.log(source);
99105
return compile(program.lang, source, {
100106
romanizeIdentifiers: program.roman,
101107
logCallback: logHandler(program.log, "a"),

0 commit comments

Comments
 (0)