Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gtt-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if (program.opts().local) {
config.assertLocalConfig();
}

Fs.open(program.opts().local ? config.local : config.global);
Fs.open(program.opts().local ? config.local : config.global);
39 changes: 39 additions & 0 deletions src/gtt-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const program = require('commander');
const colors = require('colors');
const moment = require('moment');
const Table = require('cli-table');


const Config = require('./include/file-config');
const Cli = require('./include/cli');
const Tasks = require('./include/tasks');

program
.arguments('[project]')
.option('--verbose', 'show verbose output')
.option('-c, --closed', 'show closed issues (instead of opened only)')
.option('--my', 'show only issues assigned to me')
.parse(process.argv);

Cli.verbose = program.verbose;

let config = new Config(process.cwd()),
tasks = new Tasks(config),
type = program.type ? program.type : 'issue',
project = program.args[0];

tasks.list(project, program.closed ? 'closed' : 'opened', program.my)
.then(issues => {
let table = new Table({
style : {compact : true, 'padding-left' : 1}
});
if (issues.length == 0) {
console.log("No issues found.");
}
issues.forEach(issue => {
table.push([issue.iid.toString().magenta, issue.title.green + "\n" + issue.data.web_url.gray, issue.state])
})
console.log(table.toString());
})
.catch(error => Cli.error(error));

2 changes: 1 addition & 1 deletion src/gtt-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ tasks.log()
});
}
)
.catch(error => Cli.error(error));
.catch(error => Cli.error(error));
1 change: 1 addition & 0 deletions src/gtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ program
.command('stop', 'stop monitoring time')
.command('resume [project]', 'resume monitoring time for last stopped record')
.command('cancel', 'cancel and discard active monitoring time')
.command('list [project]', 'list all open issues')
.command('log', 'log recorded time records')
.command('sync', 'sync local time records to GitLab')
.command('edit [id]', 'edit time record by the given id')
Expand Down
17 changes: 17 additions & 0 deletions src/models/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ class issue extends hasTimes {
return promise;
}

list(project, state, my) {
return new Promise((resolve, reject) => {
let promise;
const query = `scope=${my ? "assigned-to-me" : "all"}&state=${state}`;
if (project) {
promise = this.get(`projects/${encodeURIComponent(project)}/issues?${query}`);
} else {
promise = this.get(`issues/?${query}`);
}
promise.then(response => {
const issues = response.body.map(issue => new this.constructor(this.config, issue))
resolve(issues)
});
promise.catch(error => reject(error))
})
}

/*
* properties
*/
Expand Down