To do
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.
To do
textandcsvoutput (search foroutput ===).Cli.shouldTrimOutput(args.options.output)that returns aboolean.truewhen output iscsvortextfalseotherwiseOriginal Post
We have a few commands that strip the output response for
txtandcsvoutputs 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:cli-microsoft365/src/m365/pp/commands/solution/solution-list.ts
Lines 67 to 79 in 01dcbcb
We have now introduced a new output type
md. This output type doesn't takedefaultPropertiesinto account. But because of the code listed above, themdoutput 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
mdoutput receives the entire object like we do forjsoncli-microsoft365/src/m365/spo/commands/file/file-sharinglink-list.ts
Lines 96 to 108 in 01dcbcb
This works for now, until we introduce another output. Therefore I think it would be beneficial if we define somewhere which outputs take the
defaultPropertiesinto 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.