Skip to content

Drop default import of global Command (for CommonJS) #2016

Closed

Description

@shadowspawn

The default import of a global Command object (aka program) has been out of favour since Commander v5, deprecated since v7, removed from the TypeScript in v8, and never implemented for the explicit esm support (#1440).

In general with the deprecated features and behaviours, I am willing to leave them alone until they cause problems rather than aggressively remove them, to minimise breaking changes when people upgrade from old versions of Commander.

The global Command object was involved in recent problems with TypeScript (#2013 #2014), so I am suggesting removing it while I am still annoyed! 😠

To be clear, this will still work:

const { program } = require('commander');
program.parse();

And this:

const commander = require('commander');
const program = new commander.Command();
program.parse();

But this won't work anymore:

const commander = require('commander');
commander.parse();

Activity

  1. added
    semver: major
    pending release
    on Sep 15, 2023
  2. removed
    pending release
    on Feb 3, 2024
  3. shadowspawn commented on Feb 3, 2024

    @shadowspawn
    CollaboratorAuthor

    Released in Commander v12.0.0.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver: major

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions