Skip to content

M365 local context 🧺 #3896

@Adam-it

Description

@Adam-it

💡 What is the Idea

The idea here is to give users possibility to save any kind of option with defined value (key/value pairs) in a local json file. Then when any command will be executed, from the place where this file is located, CLI will first check all options defined in this file and if any may be used to fill the currently executed command. The local file created with the context structure could be the same json we use for apps .m365rc.json.

For example:

  1. user creates some context (commands not specified yet) and adds two options to it with values, as a result we have a local file created in directory C:\Test with contents
    .m365rc.json:
{
   'webUrl' : 'https://contoso.sharepoint.com/sites/test',
   'listTitle' : 'TestItem'
}
  1. then the user runs a command C:\Test> m365 spo listitem get --id 147. The user did not define the webUrl option which is a required one and listId nor listTitle to specify the list so the command should fail. But CLI will first check if any of the options defined in the .m365rc.json may be used to prefill any option in this command and if yes CLI will use them. So as a result the command will work just fine 😊

  2. the user steps out of the location C:\Test and runs the command again C:\> m365 spo listitem get --id 147. As a result the command will fail as the user did not specify needed options and there was no local context JSON file CLI could use

  3. the user goes back to C:\Test and runs the command C:\Test> m365 spo listitem get --id 147 --listTitle 'Different'. Now the command will also work and webUrl will be taken from the context but the listTitle won't as it was already defined by the user

  4. the user runs the command m365 spo list get. The command will fail. Although the webUrl option will be used which is required one, but the listTitle will not be used as the command needs title option to get the specified list.

💪 What to do ?

In order to achieve this we would need this kind of commands:

Originally Discussed in 👉 #2853

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions