Skip to content

Bug report: command name deprecation message no longer works #3151

@waldekmastykarz

Description

@waldekmastykarz

Description

CLI no longer displays deprecation messages for command name

Steps to reproduce

execute the m365 spo site classic add command with valid arguments

Expected results

A message showing that the command is deprecated and you should use spo site add instead

Actual results

No deprecation message

Diagnostics

No response

CLI for Microsoft 365 version

latest from main

nodejs version

v16

Operating system (environment)

macOS

Shell

zsh

cli doctor

No response

Additional Info

This is caused by changes that we've done at some point to allow commands to call other commands here:

// store the current command name, if any and set the name to the name of
// the command to execute
const cli = Cli.getInstance();
const parentCommandName: string | undefined = cli.currentCommandName;
cli.currentCommandName = command.getCommandName();
command.action(logger, args as any, (err: any): void => {
// restore the original command name
cli.currentCommandName = parentCommandName;

cli.currentCommandName on line 234 contains the name that was used to invoke command. When one command calls another, it contains the name of the parent command. On line 235 we're replacing it with the name of the command to execute, losing information about the originally used name that could be deprecated and for which we should show a warning. We restore the original name after the command's execution completed, but at that point it's too late, because the deprecation check already happened.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions