ding-trans
Advanced tools
Comparing version 1.0.35 to 1.0.36
#! /usr/bin/env node | ||
//业务逻辑 | ||
//1.turnout命令+中英文[args,--read,-r] | ||
//1.ding命令+中英文[args,--say,-S] | ||
//捕获参数,使用yargs.argv对象; | ||
@@ -16,7 +16,20 @@ //2.将捕获到的用户的输入参数传入有道云api的q(key)中,使用字符串拼接; | ||
let argv = require("yargs").argv, | ||
queryStr = encodeURI(argv._.join(" ")), | ||
read = argv.r || argv.read; | ||
if (!queryStr) { | ||
queryStr = encodeURI(argv._.join(" ")); | ||
// read = argv.r || argv.read; | ||
// console.log(argv); | ||
// 无参数,或帮助 | ||
if (!queryStr || argv.help == true || argv.H == true || argv.h == true) { | ||
console.log("-------------------------------"); | ||
console.log("查单词: ".bold.blue); | ||
console.log("ding [单词] 或者 [短句]", "\n"); | ||
console.log("汉译英: ".bold.red); | ||
console.log("ding [文本]", "\n"); | ||
console.log("单词/短句发音: ".bold.yellow); | ||
console.log("ding [单词] [短句] --say"); | ||
console.log("ding [单词] [短句] -S"); | ||
console.log("-------------------------------"); | ||
console.log("请在'ding'命令后输入单词或断句!"); | ||
console.log("word or sentence required..."); | ||
} else { | ||
//播放 | ||
if (argv.say == true || argv.S == true) { | ||
@@ -27,7 +40,6 @@ console.log("播放中...".green); | ||
} | ||
//查词 | ||
sendInfo(queryStr); | ||
} | ||
if (read) { | ||
console.log("waiting for the new function..."); | ||
} | ||
//格式化 | ||
function format(json) { | ||
@@ -77,3 +89,3 @@ let data = JSON.parse(json), | ||
} | ||
//发送请求 | ||
function sendInfo(query) { | ||
@@ -80,0 +92,0 @@ //发送翻译请求 |
{ | ||
"name": "ding-trans", | ||
"version": "1.0.35", | ||
"version": "1.0.36", | ||
"description": "a translation cli", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5173
113