Skip to content

Commit

Permalink
Fix #56
Browse files Browse the repository at this point in the history
`jira ls --help` will show that `jira ls -j 1` works just like `jira jql -j1 '...'`
  • Loading branch information
RichardBronosky authored and palashkulsh committed Jul 12, 2019
1 parent 5557623 commit b53bd4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 9 additions & 2 deletions bin/jira.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env node

// See: https://github.com/nodejs/node/issues/6456
[process.stdout, process.stderr].forEach((s) => {
s && !s.isTTY && s._handle && s._handle.setBlocking &&
s._handle.setBlocking(true)
})

var requirejs = require('requirejs');
// https://docs.atlassian.com/jira/REST/server/?_ga=2.55654315.1871534859.1501779326-1034760119.1468908320#api/2/issueLink-linkIssues
// https://developer.atlassian.com/jiradev/jira-apis/about-the-jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-examples#JIRARESTAPIexamples-Creatinganissueusingcustomfields
Expand Down Expand Up @@ -44,13 +50,14 @@ requirejs([
.description('List my issues')
.option('-p, --project <name>', 'Filter by project', String)
.option('-t, --type <name>', 'Filter by type', String)
.option('-j, --json <value>', 'Output in json', String, 0)
.action(function (options) {
auth.setConfig(function (auth) {
if (auth) {
if (options.project) {
ls.showByProject(options.project, options.type, finalCb);
ls.showByProject(options, finalCb);
} else {
ls.showAll(options.type, finalCb);
ls.showAll(options, finalCb);
}
}
});
Expand Down
18 changes: 10 additions & 8 deletions lib/jira/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,21 @@ define([
(halfhours > 0 ? '' + (halfhours / 2) + 'h' : '');
},

showAll: function (type, cb) {
this.type = (type) ? '+AND+type="' + type + '"' : '';
showAll: function (options, cb) {
this.type = (options && options.type) ? '+AND+type="' + options.type + '"' : '';
this.query = 'rest/api/2/search?jql=' + 'assignee=currentUser()' + this.type + '+AND+status+in+("' + this.getAvailableStatuses() + '")' + '+order+by+priority+DESC,+key+ASC' + '&maxResults=500';
return this.getIssues(cb);
return this.getIssues(options, cb);
},

showInProgress: function (cb) {
this.query = 'rest/api/2/search?jql=' + 'assignee=currentUser()' + '+AND+status+in+("In+Progress")' + '+order+by+priority+DESC,+key+ASC';
return this.getIssues(cb);
},

showByProject: function (project, type, cb) {
this.type = (type) ? '+AND+type=' + type : '';

this.query = 'rest/api/2/search?jql=' + 'assignee=currentUser()' + this.type + '+AND+project=' + project + '+AND+status+in+("' + this.getAvailableStatuses() + '")' + '+order+by+priority+DESC,+key+ASC';
return this.getIssues(cb);
showByProject: function (options, cb) {
this.type = (options && options.type) ? '+AND+type=' + options.type : '';
this.query = 'rest/api/2/search?jql=' + 'assignee=currentUser()' + this.type + '+AND+project=' + options.project + '+AND+status+in+("' + this.getAvailableStatuses() + '")' + '+order+by+priority+DESC,+key+ASC';
return this.getIssues(options, cb);
},

search: function (query, cb) {
Expand All @@ -175,12 +174,15 @@ define([
this.query = 'rest/api/2/search?jql=' + encodeURIComponent(query);
return this.getIssues(options, cb);
},

getAvailableStatuses: function () {
return config.options.available_issues_statuses.join('", "');
},

getListIssuesColumns: function() {
return config.options.list_issues_columns;
},

getWorkHoursInDay: function() {
return config.options.work_hours_in_day
},
Expand Down

0 comments on commit b53bd4d

Please sign in to comment.