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

Commit

Permalink
Label: Search via labels
Browse files Browse the repository at this point in the history
Signed-Off-By: Progyan Bhattacharya <[email protected]>
  • Loading branch information
0xTheProDev committed May 16, 2017
1 parent 7267dae commit a1c4843
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 26 deletions.
File renamed without changes
Binary file added Docs/Screenshotv1.3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ $ ghb status
```
* Get latest issues/pr from GitHub
```bash
$ ghb issues [options: open | closed | all | id={ID}]
$ ghb pulls [options: open | closed | all | id={ID}]
$ ghb issues [options: open | closed | all | id={ID} | label={LABELS}]
$ ghb pulls [options: open | closed | all | id={ID} | label={LABELS}]
```

### What's new _(v1.3.4)_
* Added markdown support for Terminal
* Improved UI quality
* User can search open issues via label(s)
* Label color resembles that on GitHub
![screen](Docs/Screenshotv1.3.png)

### Contribute
* If you find any bug register an issue.
* If you find any bug or to request new feature register an issue.
* If you want to make design improvement [comment here](https://github.com/BytesClub/ghb/issues/10).
* Look issues and try to solve them and create a pull request

Expand Down
30 changes: 19 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const helpStr =
Required parameter: [url]
status: Show current state of GHB
issues: Fetch and display issues
Optional parameter: [open / closed / all / id={ID}]
Optional parameter: [open / closed / all / id={ID} / label={LABELS}]
pulls : Fetch and display pull requests
Optional parameter: [open / closed / all / id={ID}]`,
Optional parameter: [open / closed / all / id={ID} / label={LABELS}]`,
infoStr =
`Invalid number of argumnet passed
ghb -h or ghb --help to see usage details.`
Expand Down Expand Up @@ -76,20 +76,24 @@ if ((index = argv.indexOf('-v')) !== -1 || (argv.indexOf('--version')) !== -1) {
throw err;
}
if (typeof argv[index + 1] === 'string') {
var regM = argv[index + 1].match(/id=(\d+)/i)
var regM = argv[index + 1].match(/id=(\d+)/)
var regL = argv[index + 1].match(/label=((['"])?([^'"]+)(['"])?)/)
if (regM && regM.length !== 0) {
let issueId = parseInt(regM[1])
ghb.getIssues(issueId)
ghb.getIssues({key: "id", value: issueId})
} else if(regL && regL.length !== 0) {
let label = regL[3]
ghb.getIssues({key: "label", value: label})
} else {
let state = argv[index + 1]
if (state !== 'open' && state !== 'closed' && state !== 'all'){
console.log(helpStr)
process.exit(0)
}
ghb.getIssues(state)
ghb.getIssues({key: 'state', value: state})
}
} else {
ghb.getIssues('open')
ghb.getIssues({key: 'state', value: 'open'})
}
} else if ((index = argv.indexOf('pulls')) !== -1) {
ghb = new GHT({data: {dir: CONFIG, file: FILE}, type: 'json'})
Expand All @@ -98,20 +102,24 @@ if ((index = argv.indexOf('-v')) !== -1 || (argv.indexOf('--version')) !== -1) {
throw err;
}
if (typeof argv[index + 1] === 'string') {
var regM = argv[index + 1].match(/id=(\d+)/i)
var regM = argv[index + 1].match(/id=(\d+)/)
var regL = argv[index + 1].match(/label=((['"])?([^'"]+)(['"])?)/)
if (regM && regM.length !== 0) {
let pullId = parseInt(regM[1])
ghb.getPulls(pullId)
let issueId = parseInt(regM[1])
ghb.getIssues({key: "id", value: issueId})
} else if(regL && regL.length !== 0) {
let label = regL[3]
ghb.getIssues({key: "label", value: label})
} else {
let state = argv[index + 1]
if (state !== 'open' && state !== 'closed' && state !== 'all'){
console.log(helpStr)
process.exit(0)
}
ghb.getPulls(state)
ghb.getPulls({key: 'state', value: state})
}
} else {
ghb.getPulls('open')
ghb.getPulls({key: 'state', value: 'open'})
}
} else {
console.log(infoStr)
Expand Down
2 changes: 1 addition & 1 deletion ghb-auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _ghb() {
opts=("-h" "--help" "-v" "--version" "init" "status" "issues" "pulls")
elif [[ $prev == "issues" || $prev == "pulls" ]]; then
unset opts
opts=("open" "closed" "all" "id=")
opts=("open" "closed" "all" "label=" "id=")
fi

opt=''
Expand Down
12 changes: 7 additions & 5 deletions lib/fetchissue.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ const https = require('https')
var fetchIssue = (config, flag, callback) => {
const states = ['open', 'closed', 'all']
var fg = ''
if (typeof flag == 'string' && states.indexOf(flag) !== -1)
fg = '?state=' + flag
else if (typeof flag == 'number')
fg = '/' + flag.toString()
if (flag.key === 'state' && typeof flag.value == 'string' && states.indexOf(flag.value) !== -1)
fg = '?state=' + flag.value
else if (flag.key === 'id' && typeof flag.value == 'number')
fg = '/' + flag.value.toString()
else if (flag.key === 'label' && typeof flag.value === 'string')
fg = '?labels=' + flag.value.replace(/[\s]/, '+')
else {
let err = `Invalid argument specified for fetch issue.`
throw err;
}
const pathUrl = config.url,
options = {
hostname: 'api.github.com',
path: pathUrl + '/issues' + fg,
path: encodeURI(pathUrl + '/issues' + fg),
headers: {
'Accepts': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
Expand Down
12 changes: 7 additions & 5 deletions lib/fetchpulls.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ const https = require('https')
var fetchPulls = (config, flag, callback) => {
const states = ['open', 'closed', 'all']
var fg = ''
if (typeof flag == 'string' && states.indexOf(flag) !== -1)
fg = '?state=' + flag
else if (typeof flag == 'number')
fg = '/' + flag.toString()
if (flag.key === 'state' && typeof flag.value == 'string' && states.indexOf(flag.value) !== -1)
fg = '?state=' + flag.value
else if (flag.key === 'id' && typeof flag.value == 'number')
fg = '/' + flag.value.toString()
else if (flag.key === 'label' && typeof flag.value === 'string')
fg = '?labels=' + flag.value.replace(/[\s]/, '+')
else {
let err = `Invalid argument specified for fetch pulls.`
throw err;
}
const pathUrl = config.url,
options = {
hostname: 'api.github.com',
path: pathUrl + '/pulls' + fg,
path: encodeURI(pathUrl + '/pulls' + fg),
headers: {
'Accepts': 'application/json',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghb",
"version": "1.3.3",
"version": "1.3.5",
"description": "A command line tool for GitHub Issue and Pull Request",
"main": "app.js",
"bin": {
Expand Down

0 comments on commit a1c4843

Please sign in to comment.