diff --git a/lib/color.js b/lib/color.js index 60eafc4..fc66160 100644 --- a/lib/color.js +++ b/lib/color.js @@ -10,19 +10,19 @@ var colorLabel = (color) => { switch(color) { case 'b60205': case 'd93f0b': case 'ee0701': - return '\x1b[41m\x1b[37m' + return '\x1b[41m\x1b[37m' // RED case 'fbca04': - return '\x1b[43m\x1b[30m' + return '\x1b[43m\x1b[30m' // YELLOW case '0e8a16': - return '\x1b[42m\x1b[37m' + return '\x1b[42m\x1b[37m' // GREEN case '006b75': - return '\x1b[46m\x1b[37m' + return '\x1b[46m\x1b[37m' // CYAN case '1d76db': case '0052cc': case '84b6eb': - return '\x1b[44m\x1b[37m' - case '5319e7': - return '\x1b[44m\x1b[37m' + return '\x1b[44m\x1b[37m' // BLUE + case '5319e7': case 'cc317c': + return '\x1b[45m\x1b[37m' // MAGENTA default: - return '\x1b[47m\x1b[34m' + return '\x1b[47m\x1b[34m' // WHITE } } diff --git a/lib/display.js b/lib/display.js new file mode 100644 index 0000000..f06acb5 --- /dev/null +++ b/lib/display.js @@ -0,0 +1,36 @@ +/* + * GHB - GitHub on Terminal + * Copyright (C) 2017 Progyan Bhattacharya + * Maintained by: Bytes Club (https://bytesclub.github.io) + * Distributed under MIT License. + */ + +'use strict'; + +const md = require('./markdown.js'), + col = require('./color.js') + +var display = (val) => { + // Title and Issue Number in Yellow fg + // Current State in Magenta bg and White fg + console.log('\x1b[1m\x1b[33m%s #%s\x1b[22m \x1b[45m\x1b[37m%s\x1b[0m', val.title, val.number, val.state) + // Body of issue in White fg + console.log('\x1b[37m%s\x1b[0m', md(val.body)) + val.labels.forEach((label) => { + // Labels associated + console.log('%s%s\x1b[0m\x1b[22m', col(label.color), label.name) + }) + // User-ID of creator in Cyan fg + console.log('\x1b[36mCreated by: %s', val.user.login) + if (val.assignee){ + // Assignee list in Green fg + console.log('\x1b[32mAssigned to:') + val.assignees.forEach((as) => { + console.log('* %s', as.login) + }) + } + // Reset to default + console.log('\x1b[0m') +} + +module.exports = display \ No newline at end of file diff --git a/lib/viewissue.js b/lib/viewissue.js index 7cdd857..e521e8d 100644 --- a/lib/viewissue.js +++ b/lib/viewissue.js @@ -8,30 +8,7 @@ 'use strict'; const fs = require('fs'), - md = require('./markdown.js'), - col = require('./color.js') - -var display = (val) => { - // Title and Issue Number in Yellow fg - console.log('\x1b[1m\x1b[33m%s #%s\x1b[22m', val.title, val.number) - // Body of issue in White fg - console.log('\x1b[37m%s\x1b[0m', md(val.body)) - val.labels.forEach((label) => { - // Labels associated are in Red bg and White fg - console.log('%s%s\x1b[0m\x1b[22m', col(label.color), label.name) - }) - // User-ID of creator in Cyan fg - console.log('\x1b[36mCreated by: %s\x1b[0m', val.user.login) - if (val.assignee){ - // Assignee list in Green fg - console.log('\x1b[32mAssigned to:') - val.assignees.forEach((as) => { - console.log('* %s', as.login) - }) - } - // Reset to default - console.log('\x1b[0m') -} + dsp = require('./display.js') var viewIssue = (issues, path) => { if (typeof issues === 'undefined' || issues.length === 0){ @@ -39,9 +16,9 @@ var viewIssue = (issues, path) => { return false } if (!Array.isArray(issues)) - display(issues) + dsp(issues) else - issues.forEach(display) + issues.forEach(dsp) try { if (!fs.existsSync(path.dir)) { fs.mkdirSync(path.dir) diff --git a/lib/viewpulls.js b/lib/viewpulls.js index 807f16b..761c1f1 100644 --- a/lib/viewpulls.js +++ b/lib/viewpulls.js @@ -8,27 +8,7 @@ 'use strict'; const fs = require('fs'), - md = require('./markdown.js') - -var display = (val) => { - // Title and Pull Request Number in Yellow fg - console.log('\x1b[1m\x1b[33m%s #%s\x1b[0m', val.title, val.number) - // Body of Pull Request in White fg - console.log('\x1b[37m%s\x1b[0m', md(val.body)) - // Current State in Red bg and White fg - console.log('\x1b[41m\x1b[37m%s\x1b[0m', val.state) - // User-ID of creator in Cyan fg - console.log('\x1b[36mCreated by: %s\x1b[0m', val.user.login) - if (val.assignee){ - // Assignee list in Green fg - console.log('\x1b[32mAssigned to:') - val.assignees.forEach((as) => { - console.log('* %s', as.login) - }) - } - // Reset to default - console.log('\x1b[0m') -} + dsp = require('./display.js') var viewPulls = (pulls, path) => { if (typeof pulls === 'undefined' || pulls.length === 0){