Skip to content

Commit

Permalink
Merge pull request #294 from hotoo/feat/cli-group
Browse files Browse the repository at this point in the history
feat: cli support group
  • Loading branch information
hotoo committed Apr 11, 2021
2 parents ed589e7 + 6ea1efd commit 88f5afe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/pinyin
Expand Up @@ -9,6 +9,7 @@ commander.
option('-s, --style <style>', 'pinyin styles: [NORMAL,TONE,TONE2,INITIALS,FIRST_LETTER]').
option('-S, --segment', 'segmentation word to phrases').
option('-h, --heteronym', 'output heteronym pinyins').
option('-g, --group', 'output group by phrases').
option('-p, --separator <separator>', 'separator between words').
parse(process.argv);

Expand All @@ -25,6 +26,7 @@ var pinyin = require("../");
var options = {
style: pinyin["STYLE_" + (commander.style || "TONE").toUpperCase()],
heteronym: commander.heteronym || false,
group: commander.group || false,
segment: commander.segment || false,
};

Expand Down
4 changes: 4 additions & 0 deletions tests/cli.test.js
Expand Up @@ -55,6 +55,10 @@ var testcases = [
command: "pinyin -p '' -s normal 重复",
stdout: "zhongfu",
},
{
command: "pinyin -Sg 我喜欢你",
stdout: "wǒ xǐhuān nǐ",
},

];

Expand Down

0 comments on commit 88f5afe

Please sign in to comment.