命令行板块,增加帮助菜单,增强版本号显示

This commit is contained in:
TevinLi 2017-03-29 20:43:47 +08:00
parent eda097277b
commit d6a81b21c9
4 changed files with 66 additions and 13 deletions

View File

@ -55,10 +55,10 @@ co(function*() {
}
const type = parameters[0];
//更新导航
if (type === 'nav' || type === 'navigation') {
if (type === 'nav') {
makeNav.refresh(root);
}
//更新植入文库数据
//更新文库嵌入数据
else if (type === 'embed') {
}
//更新 SEO 模块
@ -123,16 +123,18 @@ co(function*() {
outPath = outPath.replace(/\\/g, '/');
yield exportGithub.export(root, outPath);
break;
//显示帮助
case 'help':
case '-h':
printFn.help();
break;
//显示版本号
case 'version':
case '-v':
printFn.ver();
printFn.ver(mainPath);
break;
//显示帮助
case 'help':
case '-h':
default:
printFn.help();
break;
}
//关闭用户输入

View File

@ -58,15 +58,65 @@ console.error = (...content) => {
return console.log(`${clc(41, 'ERROR:')}`, ...content);
};
const helpWords = `
用法
amwiki [command] [arguments]
命令列表
-h, help 显示帮助
-v, version 显示版本号
-c, create 创建 wiki
-u, update 更新 wiki 数据
默认全部项目更新添加参数可以指定部分更新
[nav] 仅更新导航
${clc(90, '(eg: amwik update nav)')}
-s, server 启动本地服务器
默认本地服务器使用端口5171添加参数可以修改端口
[5171] 修改端口(待开发)
${clc(90, '(eg: amwiki server 8080)')}
-b, browser 本地浏览文档
默认访问文库首页添加参数可以打开指定页面
[002/001] 按目录文档的id打开指定文档(待开发)
${clc(90, '(eg: amwiki browser 002/001)')}
-e, export 项目导出
第一位参数必需指定导出类型
github-wiki 导出为github的项目wiki
第二位参数必需指定导出路径
d:/your-path
${clc(90, '(eg: amwiki export github-wiki d:/your-path)')}
更多文档
https://tevinli.github.io/amWiki/index.html`;
//[embed] 仅更新嵌入数据(待开发)
//[seo] 仅更新SEO模块(待开发)
const vesWords = `
kk kk kk kk ww
wwwwww www www kk kk kk
ww ww ww ww kk kk kk kk kk kk kk
wwwwwww ww ww ww kk kkkk kk kk kk kk kk
ww ww ww ww ww kk kk kk kk kk kkkk kk
wwwwwww ww ww ww kk kk kk kk kk kk
`.replace(/w/g, `${clc(32, '$')}`).replace(/k/g, `${clc(36, '$')}`);
module.exports = {
clc: clc,
help: function () {
alert('coming soon!')
alert(helpWords);
},
ver: function (mainPath) {
const packageStr = fs.readFileSync(mainPath.replace(/bin[\\\/]main$/, '') + 'package.json', 'utf-8');
const packageConf = JSON.parse(packageStr);
const text = ` ${clc(92, 'am')}${clc(96, 'Wiki')} ${clc(1, 'v' + packageConf.version)}`;
alert(text);
const text = [
'Package: amWiki',
`Version: ${clc(0, packageConf.version)}`,
'Author: Tevin Li',
'HomePage: https://github.com/tevinli/amWiki',
'License: MIT'
];
//const text = ` ${clc(92, 'am')}${clc(96, 'Wiki')} ${clc(1, 'v' + packageConf.version)}`;
alert(vesWords + text.join('\n'));
}
};

View File

@ -1,6 +1,6 @@
/**
* @desc 工作端·主模块
* @author Tevin
* @author Tevin Li
* @see {@link https://github.com/TevinLi/amWiki}
* @license MIT - Released under the MIT license.
*/

View File

@ -17,7 +17,8 @@
},
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
"atom": ">=1.0.0 <2.0.0",
"node": ">=1.0.0"
},
"bugs": {
"url": "https://github.com/TevinLi/amWiki/issues"