Skip to content

Markdown response output is sometimes stripped #4288

@milanholemans

Description

@milanholemans

To do

  • Make a list of all commands that modify the output for text and csv output (search for output === ).
  • Create a new function Cli.shouldTrimOutput(args.options.output) that returns a boolean.
    • Returns true when output is csv or text
    • Returns false otherwise
  • Update all commands that modify their output to use this new function.

Original Post

We have a few commands that strip the output response for txt and csv outputs so the default properties don't get polluted with nested objects or arrays. This makes sure that we have a clean output for these types. How we usually enforce this is by doing an output check before logging the response, example:

if (!args.options.output || args.options.output === 'json') {
logger.log(res);
}
else {
//converted to text friendly output
logger.log(res.map(i => {
return {
uniquename: i.uniquename,
version: i.version,
publisher: (i.publisherid as Publisher).friendlyname
};
}));
}

We have now introduced a new output type md. This output type doesn't take defaultProperties into account. But because of the code listed above, the md output will also contain the stripped response.
According to me, this is not what we want.

In a recent approved PR we made sure that the md output receives the entire object like we do for json

if (!args.options.output || args.options.output === 'json' || args.options.output === 'md') {
logger.log(sharingLinks);
}
else {
//converted to text friendly output
logger.log(sharingLinks.map(i => {
return {
id: i.id,
roles: i.roles.join(','),
link: i.link.webUrl
};
}));
}

This works for now, until we introduce another output. Therefore I think it would be beneficial if we define somewhere which outputs take the defaultProperties into account and expect (sometimes) modified results. If we do this and update all commands that perform an output check to use this centralized value, all commands will display the output correctly in the future as well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions