When thinking about the m365 identity set command we discussed that it should be possible on that command to prompt the user with a list of available identities to choose from.
However, that is a nice idea, but currently not supported. In the current situation, the CLI prompts for required values or for optionSet values using default text-input prompt. Which means manual typing...
💡 Idea
I'd like us to help the user by overriding option prompts in this and other scenario's.
-
In the scenario of m365 identity set, we'd much rather prompt the user to SELECT one of the available identities (instead of manually typing the emailaddress or user ID.
-
Another example that comes to mind is the --password option on the m365 login command. That option could be prompted when the --authType is password, the prompt override could use inquirers password input to mask the values that the user types in.
This must be configurable on an option by option basis. But the CLI engine should call the prompts, just like it's doing now with the required options and optionSet prompts.
⚙️ Implementation
My idea on how to do this would be to add an extra optional property to the optionslist that can be used to override prompt behavior on such an option. In the below example, you can see how I'd override the prompts on the id and name options to make it possible to prompt based on a list of identities, instead of a free input prompt.
#initOptions(): void {
this.options.unshift(
{
option: '-n, --name [name]',
whenPrompted: () => prompt.forInput({ type: 'select', message: 'Please select one of the available identities', choices: this.getIdentitiesAsOptions() });
},
{
option: '-i, --id [id]',
whenPrompted: () => prompt.forInput({ type: 'select', message: 'Please select one of the available identities', choices: this.getIdentitiesAsOptions() });
}
}
We'd need to update the following code:
// File: /workspaces/cli-microsoft365/src/cli/Cli.ts
private static getCommandOptions(command: Command): CommandOptionInfo[];
// File: /workspaces/cli-microsoft365/src/cli/CommandOptionInfo.ts
// Add the prompt override to this interface ass well:
interface CommandOptionInfo
And then implement the actual prompting from within Cli.ts / Command.ts.
When thinking about the m365 identity set command we discussed that it should be possible on that command to prompt the user with a list of available identities to choose from.
However, that is a nice idea, but currently not supported. In the current situation, the CLI prompts for required values or for optionSet values using default text-input prompt. Which means manual typing...
💡 Idea
I'd like us to help the user by overriding option prompts in this and other scenario's.
In the scenario of
m365 identity set, we'd much rather prompt the user to SELECT one of the available identities (instead of manually typing the emailaddress or user ID.Another example that comes to mind is the
--passwordoption on them365 logincommand. That option could be prompted when the--authTypeispassword, the prompt override could use inquirers password input to mask the values that the user types in.This must be configurable on an option by option basis. But the CLI engine should call the prompts, just like it's doing now with the required options and optionSet prompts.
⚙️ Implementation
My idea on how to do this would be to add an extra optional property to the optionslist that can be used to override prompt behavior on such an option. In the below example, you can see how I'd override the prompts on the
idandnameoptions to make it possible to prompt based on a list of identities, instead of a free input prompt.We'd need to update the following code:
And then implement the actual prompting from within Cli.ts / Command.ts.