savory
Version:
A command-line interface for operating your Codefresh account
32 lines (30 loc) • 1.05 kB
JavaScript
const
fp = require('lodash/fp'),
jsYaml = require('js-yaml'),
{ middleware: httpClientMiddleware } = require('../../lib/api_client'),
{
tableFormatter,
jsonFormatter,
errorFormatter
} = require('../style');
module.exports = {
command: ["list", "ls"],
description: "List your configured pipeline triggers",
builder: (yargs)=> {
return yargs
.option('output', {
choices: ["summary", "yaml", "json"],
default: "summary",
describe: "Choose a output format for the returned data"
})
.example('$0 triggers list');
},
handler: fp.pipe(httpClientMiddleware, (({ _httpClient, output })=> {
_httpClient('hermes/triggers/')
.then(fp.pipe(
{ "summary": tableFormatter({ column: ["event", "pipeline"] }), "json": jsonFormatter, "yaml": jsYaml.safeDump }[output],
console.log
))
.catch(fp.pipe(errorFormatter, console.warn))
}))
};