You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to automate using the contentful cli, for example get a list of spaces the cli user has access too that I can pass to a shell script or tool like jq
Actual Behavior
When I run the command I get a table output, currently most list command use the table from cli-table3, and don't support other outputs, limiting the CLI use.
Possible Solution
Provide a --plain or --json like argument to commands like contentful space list that provides a plain output, for example:
module.exports.builder=yargs=>{returnyargs.usage('Usage: contentful space list').option('management-token',{alias: 'mt',describe: 'Contentful management API token',type: 'string'}).option('header',{alias: 'H',type: 'string',describe: 'Pass an additional HTTP Header'}).option('json',{alias: 'j',describe: 'Enables JSON output',type: 'boolean'}).epilog(['See more at:','https://github.com/contentful/contentful-cli/tree/master/docs/space/list',copyright].join('\n'))}module.exports.aliases=['ls']asyncfunctionspaceList({ context, header }){const{ managementToken, activeSpaceId, json }=contextconstclient=awaitcreateManagementClient({accessToken: managementToken,feature: 'space-list',headers: getHeadersFromOption(header)})constresult=awaitpaginate({ client,method: 'getSpaces'})constspaces=result.items.sort((a,b)=>a.name.localeCompare(b.name))if(json){log(JSON.stringify({ spaces }))// This will output an object with a key spaces, and the value the array of spacesreturn}consttable=newTable({head: ['Space name','Space id']})
Context
With GitHub Actions for example, with a JSON output of a command such as contentful space list, it can be passed to a matrix of an array of spaces, this can allow for automation of backup to an assigned user or application with permission over several spaces.
The text was updated successfully, but these errors were encountered:
Expected Behavior
I'd like to automate using the contentful cli, for example get a list of spaces the cli user has access too that I can pass to a shell script or tool like
jq
Actual Behavior
When I run the command I get a table output, currently most
list
command use the table from cli-table3, and don't support other outputs, limiting the CLI use.Possible Solution
Provide a
--plain
or--json
like argument to commands likecontentful space list
that provides a plain output, for example:Context
With GitHub Actions for example, with a JSON output of a command such as
contentful space list
, it can be passed to amatrix
of an array of spaces, this can allow for automation of backup to an assigned user or application with permission over several spaces.The text was updated successfully, but these errors were encountered: