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

feat: support flag and command deprecations #511

Merged
merged 6 commits into from Oct 14, 2022

Conversation

mdonnalley
Copy link
Contributor

Support deprecation warnings for flags and commands

Commands

export default class MyCommand extends Command {
  static state = 'deprecated'
}
Warning: The "my command" command has been deprecated.
export default class MyCommand extends Command {
  static state = 'deprecated'
  static deprecationOptions = {
    to: 'my other command"
    version: '2.0.0',
  }
}
Warning: The "my command" command has been deprecated and will be removed in version 2.0.0. Use "my other command" instead.

Flags

export default class MyCommand extends Command {
  static flags = {
    name: Flags.string({
      char: 'n',
      summary: 'Name to print.',
      deprecated: {
        to: 'full-name',
        version: '2.0.0',
      }
    }),
   'full-name': Flags.string({
      summary: 'Name to print.',
    }),
  }
}
Warning: The "name" flag has been deprecated and will be removed in version 2.0.0. Use "full-name" instead.
export default class MyCommand extends Command {
  static flags = {
    name: Flags.string({
      char: 'n',
      summary: 'Name to print.',
      deprecated: true
    }),
  }
}
Warning: The "name" flag has been deprecated.

@W-11836498@

@@ -97,3 +98,32 @@ export function getHelpFlagAdditions(config: IConfig): string[] {
const additionalHelpFlags = config.pjson.oclif.additionalHelpFlags ?? []
return [...new Set([...helpFlags, ...additionalHelpFlags]).values()]
}

export function formatFlagDeprecationWarning(flag: string, opts: true | Deprecation): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there's only 1 word of difference, it could be consolidated?
formatDeprecationWarning(deprecationType: 'command' | 'flag', item: string, opts: true | Deprecation)

mshanemc
mshanemc previously approved these changes Oct 5, 2022
Copy link
Member

@mshanemc mshanemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 non-blocking suggestion comment.

can you also put on here what, if anything, needs to be done or should be done for SfdxCommand as a result of this?

Are the deprecations compatible? Does this get overridden in sfdxCommand? Should sfdxCommand remove its code for this and rely directly on oclif's ?

@@ -57,7 +57,7 @@ describe('Config with flexible taxonomy', () => {

const load = async (): Promise<void> => {}
const findCommand = async (): Promise<ICommand.Class> => {
return new MyComandClass() as unknown as ICommand.Class
return new MyCommandClass() as unknown as ICommand.Class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for that!

@mshanemc mshanemc merged commit b0bf379 into main Oct 14, 2022
@mshanemc mshanemc deleted the mdonnalley/support-deprecations branch October 14, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants