Opened 17 years ago

Last modified 17 years ago

#5369 closed

Allow commands to register their own options (and refactor help to reflect this) — at Initial Version

Reported by: toddobryan@… Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Keywords: command
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After the refactoring of django.core.management, it was clear that having one universal set of options was less elegant than allowing each command to register just those options it allows. This refactoring keeps exactly the same functionality, but separates out the options. Any subclass of BaseCommand can provide its own option_list (with each option created using optparse.make_option). It inherits all the options in its class hierarchy. (One caveat: BaseCommand subclasses can only extend one superclass. I think handling multiple inheritance is possible, but I'm not sure how much harder it would be and can't think of a reasonable use case that would require it.)

There is a slight backwards incompatibility.{{{
django-admin.py --option command
}}} must now be written as {{{
django-admin.py command --option
}}}

Change History (1)

by toddobryan@…, 17 years ago

Attachment: command.patch added

patch implementing the refactoring

Note: See TracTickets for help on using tickets.
Back to Top