|
|
|
@ -5,7 +5,6 @@
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
var getContents = require('../lib/fileio').getContents;
|
|
|
|
|
var convert = require('../lib/fileio').convert;
|
|
|
|
|
var processMd = require('../lib/fileio').processMd;
|
|
|
|
|
var narrowDown = require('../lib/find').narrowDown;
|
|
|
|
|
var selectArticle = require('../lib/find').selectArticle;
|
|
|
|
|
var tmpSave = require('../lib/fileio').tmpSave;
|
|
|
|
@ -82,33 +81,48 @@ if (lang !== 'english') {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Promise.resolve(narrowDown(articles, searchTerms, isDeep, isApro, doFallback, englishArticles)).then(function select(filteredArticles) {
|
|
|
|
|
|
|
|
|
|
return selectArticle(filteredArticles, lang, searchTerms, isDeep, isApro, englishArticles);
|
|
|
|
|
|
|
|
|
|
}).then(function makeRoff(selectedArticle) {
|
|
|
|
|
|
|
|
|
|
return getContents(selectedArticle);
|
|
|
|
|
|
|
|
|
|
}).then(function processArticle(article) {
|
|
|
|
|
|
|
|
|
|
if (isWeb) {
|
|
|
|
|
spawn('xdg-open', [article.url]);
|
|
|
|
|
process.exit();
|
|
|
|
|
} else {
|
|
|
|
|
return processMd(article);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return article;
|
|
|
|
|
|
|
|
|
|
}).then(function passToRemarkMan(article) {
|
|
|
|
|
|
|
|
|
|
options.name = article.title;
|
|
|
|
|
options.manual = article.url;
|
|
|
|
|
// options.description = article.description;
|
|
|
|
|
|
|
|
|
|
return convert(article.contents, options);
|
|
|
|
|
|
|
|
|
|
}).then(function saveTmpFile(roff) {
|
|
|
|
|
|
|
|
|
|
return tmpSave(roff);
|
|
|
|
|
|
|
|
|
|
}).then(function displayRoff(tmpFile) {
|
|
|
|
|
|
|
|
|
|
var man = spawn('man', [tmpFile], { stdio: 'inherit' });
|
|
|
|
|
|
|
|
|
|
man.on('exit', function onExit() {
|
|
|
|
|
Promise.resolve(removeTmp()).then(function done() {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).catch(function catchAll(err) {
|
|
|
|
|
|
|
|
|
|
console.error(chalk.red(err));
|
|
|
|
|
|
|
|
|
|
if (err.stack) {
|
|
|
|
|
console.log(chalk.yellow(err.stack));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|