Skip to content

Commit

Permalink
Merge b7de379 into 53e2793
Browse files Browse the repository at this point in the history
  • Loading branch information
ngfw committed May 18, 2017
2 parents 53e2793 + b7de379 commit 7a06832
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
7 changes: 2 additions & 5 deletions README.md
@@ -1,9 +1,6 @@
# RedmineCLI [![Build Status](https://travis-ci.org/a11n/RedmineCLI.svg)](https://travis-ci.org/a11n/RedmineCLI) [![Coverage Status](https://coveralls.io/repos/a11n/RedmineCLI/badge.svg)](https://coveralls.io/r/a11n/RedmineCLI) [![npm version](http://img.shields.io/npm/v/redmine-cli.svg?style=flat)](https://www.npmjs.com/package/redmine-cli) [![npm license](https://img.shields.io/npm/l/redmine-cli.svg)](https://www.npmjs.com/package/redmine-cli)
A NodeJS, stateful, console-based Redmine client.

## Deprecated
**This project is deprecated. There will be no new development on this project.**

## Installation & Setup
```shell
npm install -g redmine-cli
Expand Down Expand Up @@ -35,8 +32,8 @@ create-issue [options] <project> <subject> Create a new issue.
statuses Display available issue statuses.
trackers Display available trackers.
priorities Display available priorities.
users Display users (requires admin priviliges).
user <id> Display user details (requires admin priviliges).
users Display users (requires admin privileges).
user <id> Display user details (requires admin privileges).
open <id> Open issue in default browser.


Expand Down
14 changes: 13 additions & 1 deletion module/actions.js
Expand Up @@ -11,7 +11,19 @@ exports.handleConnect = function(url, apiKey){

exports.handleProjects = function(){
try{
var projects = redmine.getProjects();
var offset = 0,
limit = 100
projects = redmine.getProjects(offset, limit),
uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
},
total_runs = Math.ceil(projects.total_count / ((offset+1)*limit));
for(offset; offset<total_runs; offset++){
tmp_projects = redmine.getProjects(offset*limit+1, limit);
projects.projects = uniqueArray(projects.projects.concat(tmp_projects.projects));
}
printer.printProjects(projects);
} catch(err){console.error(err)}
}
Expand Down
4 changes: 2 additions & 2 deletions module/redmine.js
Expand Up @@ -51,10 +51,10 @@ exports.connect = function(serverUrl, apiKey){
return user;
}

exports.getProjects = function(){
exports.getProjects = function(offset, limit){
throwWhenNotConnected();

var response = get('/projects.json');
var response = get('/projects.json?offset=' + offset + '&limit=' + limit);
try{
return JSON.parse(response.getBody('utf8'));
} catch(err) {throw 'Could not load projects.'}
Expand Down

0 comments on commit 7a06832

Please sign in to comment.