Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
50 changes: 26 additions & 24 deletions lib/interface/cli/commands/project/get.cmd.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Command = require('../../Command');
const CFError = require('cf-errors');
const { sdk } = require('../../../../logic');
const Project = require('../../../../logic/entities/Project');
const Output = require('../../../../output/Output');
Expand All @@ -17,34 +18,32 @@ const command = new Command({
category: 'Projects',
title: 'Get Projects',
},
builder: (yargs) => {
return yargs
.positional('id|name', {
describe: 'Project id or name to get one project',
})
.option('name', {
alias: 'n',
describe: 'Project name to filter by',
})
.option('tag', {
alias: 't',
describe: 'Project tags array to filter by',
array: true,
})
.option('limit', {
describe: 'Limit amount of returned results',
default: DEFAULTS.GET_LIMIT_RESULTS,
})
.option('page', {
describe: 'Paginated page',
default: DEFAULTS.GET_PAGINATED_PAGE,
});
},
builder: yargs => yargs
.positional('id|name', {
describe: 'Project id or name to get one project',
})
.option('name', {
alias: 'n',
describe: 'Project name to filter by',
})
.option('tag', {
alias: 't',
describe: 'Project tags array to filter by',
array: true,
})
.option('limit', {
describe: 'Limit amount of returned results',
default: DEFAULTS.GET_LIMIT_RESULTS,
})
.option('page', {
describe: 'Paginated page',
default: DEFAULTS.GET_PAGINATED_PAGE,
}),
handler: async (argv) => {
const { id, name, limit, page, tag: tags } = argv; // eslint-disable-line
const offset = (page - 1) * limit;

let projects;
let projects = [];
if (id) {
let project = await sdk.projects.get({ id }).catch(ignoreHttpError);
project = project || await sdk.projects.getByName({ name, tags }).catch(ignoreHttpError);
Expand All @@ -58,6 +57,9 @@ const command = new Command({
});
projects = result.projects; // eslint-disable-line
}
if (!projects.length) {
throw new CFError('No projects found');
}
Output.print(_.map(projects, Project.fromResponse));
},
});
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": "codefresh",
"version": "0.52.2",
"version": "0.52.3",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down