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

Commit a1c4843

Browse files
committed
Label: Search via labels
Signed-Off-By: Progyan Bhattacharya <[email protected]>
1 parent 7267dae commit a1c4843

File tree

8 files changed

+45
-26
lines changed

8 files changed

+45
-26
lines changed
File renamed without changes.

Docs/Screenshotv1.3.png

50.3 KB
Loading

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ $ ghb status
3232
```
3333
* Get latest issues/pr from GitHub
3434
```bash
35-
$ ghb issues [options: open | closed | all | id={ID}]
36-
$ ghb pulls [options: open | closed | all | id={ID}]
35+
$ ghb issues [options: open | closed | all | id={ID} | label={LABELS}]
36+
$ ghb pulls [options: open | closed | all | id={ID} | label={LABELS}]
3737
```
3838

39+
### What's new _(v1.3.4)_
40+
* Added markdown support for Terminal
41+
* Improved UI quality
42+
* User can search open issues via label(s)
43+
* Label color resembles that on GitHub
44+
![screen](Docs/Screenshotv1.3.png)
45+
3946
### Contribute
40-
* If you find any bug register an issue.
47+
* If you find any bug or to request new feature register an issue.
4148
* If you want to make design improvement [comment here](https://github.com/BytesClub/ghb/issues/10).
4249
* Look issues and try to solve them and create a pull request
4350

app.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ const helpStr =
4242
Required parameter: [url]
4343
status: Show current state of GHB
4444
issues: Fetch and display issues
45-
Optional parameter: [open / closed / all / id={ID}]
45+
Optional parameter: [open / closed / all / id={ID} / label={LABELS}]
4646
pulls : Fetch and display pull requests
47-
Optional parameter: [open / closed / all / id={ID}]`,
47+
Optional parameter: [open / closed / all / id={ID} / label={LABELS}]`,
4848
infoStr =
4949
`Invalid number of argumnet passed
5050
ghb -h or ghb --help to see usage details.`
@@ -76,20 +76,24 @@ if ((index = argv.indexOf('-v')) !== -1 || (argv.indexOf('--version')) !== -1) {
7676
throw err;
7777
}
7878
if (typeof argv[index + 1] === 'string') {
79-
var regM = argv[index + 1].match(/id=(\d+)/i)
79+
var regM = argv[index + 1].match(/id=(\d+)/)
80+
var regL = argv[index + 1].match(/label=((['"])?([^'"]+)(['"])?)/)
8081
if (regM && regM.length !== 0) {
8182
let issueId = parseInt(regM[1])
82-
ghb.getIssues(issueId)
83+
ghb.getIssues({key: "id", value: issueId})
84+
} else if(regL && regL.length !== 0) {
85+
let label = regL[3]
86+
ghb.getIssues({key: "label", value: label})
8387
} else {
8488
let state = argv[index + 1]
8589
if (state !== 'open' && state !== 'closed' && state !== 'all'){
8690
console.log(helpStr)
8791
process.exit(0)
8892
}
89-
ghb.getIssues(state)
93+
ghb.getIssues({key: 'state', value: state})
9094
}
9195
} else {
92-
ghb.getIssues('open')
96+
ghb.getIssues({key: 'state', value: 'open'})
9397
}
9498
} else if ((index = argv.indexOf('pulls')) !== -1) {
9599
ghb = new GHT({data: {dir: CONFIG, file: FILE}, type: 'json'})
@@ -98,20 +102,24 @@ if ((index = argv.indexOf('-v')) !== -1 || (argv.indexOf('--version')) !== -1) {
98102
throw err;
99103
}
100104
if (typeof argv[index + 1] === 'string') {
101-
var regM = argv[index + 1].match(/id=(\d+)/i)
105+
var regM = argv[index + 1].match(/id=(\d+)/)
106+
var regL = argv[index + 1].match(/label=((['"])?([^'"]+)(['"])?)/)
102107
if (regM && regM.length !== 0) {
103-
let pullId = parseInt(regM[1])
104-
ghb.getPulls(pullId)
108+
let issueId = parseInt(regM[1])
109+
ghb.getIssues({key: "id", value: issueId})
110+
} else if(regL && regL.length !== 0) {
111+
let label = regL[3]
112+
ghb.getIssues({key: "label", value: label})
105113
} else {
106114
let state = argv[index + 1]
107115
if (state !== 'open' && state !== 'closed' && state !== 'all'){
108116
console.log(helpStr)
109117
process.exit(0)
110118
}
111-
ghb.getPulls(state)
119+
ghb.getPulls({key: 'state', value: state})
112120
}
113121
} else {
114-
ghb.getPulls('open')
122+
ghb.getPulls({key: 'state', value: 'open'})
115123
}
116124
} else {
117125
console.log(infoStr)

ghb-auto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _ghb() {
1919
opts=("-h" "--help" "-v" "--version" "init" "status" "issues" "pulls")
2020
elif [[ $prev == "issues" || $prev == "pulls" ]]; then
2121
unset opts
22-
opts=("open" "closed" "all" "id=")
22+
opts=("open" "closed" "all" "label=" "id=")
2323
fi
2424

2525
opt=''

lib/fetchissue.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ const https = require('https')
1212
var fetchIssue = (config, flag, callback) => {
1313
const states = ['open', 'closed', 'all']
1414
var fg = ''
15-
if (typeof flag == 'string' && states.indexOf(flag) !== -1)
16-
fg = '?state=' + flag
17-
else if (typeof flag == 'number')
18-
fg = '/' + flag.toString()
15+
if (flag.key === 'state' && typeof flag.value == 'string' && states.indexOf(flag.value) !== -1)
16+
fg = '?state=' + flag.value
17+
else if (flag.key === 'id' && typeof flag.value == 'number')
18+
fg = '/' + flag.value.toString()
19+
else if (flag.key === 'label' && typeof flag.value === 'string')
20+
fg = '?labels=' + flag.value.replace(/[\s]/, '+')
1921
else {
2022
let err = `Invalid argument specified for fetch issue.`
2123
throw err;
2224
}
2325
const pathUrl = config.url,
2426
options = {
2527
hostname: 'api.github.com',
26-
path: pathUrl + '/issues' + fg,
28+
path: encodeURI(pathUrl + '/issues' + fg),
2729
headers: {
2830
'Accepts': 'application/json',
2931
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'

lib/fetchpulls.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ const https = require('https')
1212
var fetchPulls = (config, flag, callback) => {
1313
const states = ['open', 'closed', 'all']
1414
var fg = ''
15-
if (typeof flag == 'string' && states.indexOf(flag) !== -1)
16-
fg = '?state=' + flag
17-
else if (typeof flag == 'number')
18-
fg = '/' + flag.toString()
15+
if (flag.key === 'state' && typeof flag.value == 'string' && states.indexOf(flag.value) !== -1)
16+
fg = '?state=' + flag.value
17+
else if (flag.key === 'id' && typeof flag.value == 'number')
18+
fg = '/' + flag.value.toString()
19+
else if (flag.key === 'label' && typeof flag.value === 'string')
20+
fg = '?labels=' + flag.value.replace(/[\s]/, '+')
1921
else {
2022
let err = `Invalid argument specified for fetch pulls.`
2123
throw err;
2224
}
2325
const pathUrl = config.url,
2426
options = {
2527
hostname: 'api.github.com',
26-
path: pathUrl + '/pulls' + fg,
28+
path: encodeURI(pathUrl + '/pulls' + fg),
2729
headers: {
2830
'Accepts': 'application/json',
2931
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghb",
3-
"version": "1.3.3",
3+
"version": "1.3.5",
44
"description": "A command line tool for GitHub Issue and Pull Request",
55
"main": "app.js",
66
"bin": {

0 commit comments

Comments
 (0)