Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CLI runtime: define option output with the default type #3445

Closed
Jwaegebaert opened this issue Jun 26, 2022 · 3 comments
Closed

Update CLI runtime: define option output with the default type #3445

Jwaegebaert opened this issue Jun 26, 2022 · 3 comments

Comments

@Jwaegebaert
Copy link
Contributor

Currently, we use several different ways to check if a certain output type is requested. With the change of v4, the default output type has been changed from text to json. This "breaks" several commands that check if the output type is a certain value. I am using quotes here because it doesn't reject the command but doesn't use correct the condition. e.g. of the command m365 planner task checklistitem add.

afbeelding

afbeelding

Notice here the Id value. When I pass the option -o json . I would expect to get the same response as the first image, but this isn't the case. The command uses if (args.options.output === 'json') to check if the output type is json. Here we don't take into consideration what the default output type is.

This also relates to a recently found bug #3400 which caused an option to be unavailble without an explicit ouput type.

With this all in mind, I would suggest to create a new utils function that can validate if the output is a certain type. This new function would take in mind the current default output type and can be used in the following commands.

  • m365 aad approleassignment add
  • m365 graph schemaextension list
  • m365 planner task checklistitem add
  • m365 spfx project externalize
  • m365 spo search
  • m365 spo app add
  • m365 spo customaction list
  • m365 spo file list
  • m365 spo file sharinginfo get
  • m365 spo listitem get
  • m365 spo listitem list
  • m365 spo page column get
  • m365 spo page column list
  • m365 spo page section get
  • m365 spo page section list
  • m365 spo sitedesign run list
  • m365 spo tenant recyclebinitem list
  • m365 spo userprofile get
  • m365 spo web list
  • m365 teams chat message list
  • m365 teams message list
  • m365 teams message reply list
  • m365 teams user app list
  • m365 tenant report office365activationcounts
  • m365 tenant report office365activationsusercounts
  • m365 tenant report office365activationsuserdetail
  • m365 todo task list
  • m365 yammer search

All of these commands ignore the default output type, so they need to be adjusted to take this into consideration.

@waldekmastykarz
Copy link
Member

Good catch! I wonder if the best way around it would be, to set the output to the default output in the CLI runtime, if no output type has been specified. That way, in each command we'd have the output option set and would correctly evaluate the condition.

Basically, we'd update this line and replace at the end undefined with json

optionsWithoutShorts.options.output = this.getSettingWithDefaultValue<string | undefined>(settingsNames.output, undefined);

@Jwaegebaert
Copy link
Contributor Author

That's even a beter idea, This way we don't need to check if the output option is empty and the conditions used in the commands should be correct again. 😄

@Jwaegebaert Jwaegebaert changed the title New utils function: validating the used output Update CLI runtime: define option output with the default type Jun 27, 2022
@plamber
Copy link
Contributor

plamber commented Jul 9, 2022

@waldekmastykarz: I am with your suggestion. I think updating the default output to JSON there should do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants