Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
Display: Splitted display code with label spec
Browse files Browse the repository at this point in the history
Signed-Off-By: Progyan Bhattacharya <[email protected]>
  • Loading branch information
0xTheProDev committed May 14, 2017
1 parent 5a5001a commit 7267dae
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 55 deletions.
16 changes: 8 additions & 8 deletions lib/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
36 changes: 36 additions & 0 deletions lib/display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* GHB - GitHub on Terminal
* Copyright (C) 2017 Progyan Bhattacharya <[email protected]>
* Maintained by: Bytes Club (https://bytesclub.github.io)<[email protected]>
* 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
29 changes: 3 additions & 26 deletions lib/viewissue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,17 @@
'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){
console.error('No Issue to show!')
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)
Expand Down
22 changes: 1 addition & 21 deletions lib/viewpulls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 7267dae

Please sign in to comment.