Requests for comment/Proper command-line runner for maintenance tasks

Your comments here.

Background
MediaWiki maintenance scripts are used ...

Problem
is a mess: it contains over 150 PHP scripts, which range from essential to obscure or obsolete, with no sign-posts to guide the user to the one she needs or to facilitate discovery. Were the README and online documentation comprehensive and current, they would still not be an adequate substitute for a good command-line interface.

Proposal
This RFC proposes to introduce a top-level command-line entry-point to MediaWiki which would provide access to individual maintenance tasks via subcommands. If the user does not specify a subcommand, a listing of the most commonly-used maintenance script should be enumerated, with appropriate in-line help, and presented to the user along with a tip on how to access detailed help for a particular subcommand.

This proposal could be implemented simply and without breaking backward-compatibility. The maintenance/ file hierarchy will stay and users will continue to be able to execute maintenance scripts directly. (This guarantee should not extend to future maintenance tasks, as a way of gradually driving users to adopt the top-level entry-point.)

The scaffolding for this design is the existing Maintenance class hierarchy, which already does most of the heavy lifting we need. It may need to be extended to provide a means for subclasses to customize the name of the subcommand to which they bind (the default implementation would simply use the class name) and to declare visibility, which would determine whether the subcommand is enumerated by default when the top-level entry-point is invoked without arguments (like  and   do).

Because the entry-point script would have to be aware of (and capable of inspecting) Maintenance subclasses, the files in  must be audited to ensure they are safe to include (i.e., they have no code with side-effects in file scope). The top-level entry-point script could then walk the  hierarchy and include each PHP file it encounters. It could then iterate on, looking for Maintenance subclasses.

Extensions should be able to register additional subcommands. This could be done by extending the  schema or by providing a hook that extensions can use to register subcommands, similar to the way the   and   hooks allow extensions to declare unit tests and ResourceLoader modules.