Monkey-patch the help text when showing management command help in rb-site.

Review Request #11361 — Created Jan. 7, 2021 and submitted

Information

Review Board
release-4.0.x

Reviewers

When running rb-site manage ... <command> --help, we'd show the
standard management command help text that Django displays. This would
end up showing the wrong program invocation, which wasn't helpful. For
instance:

rbsite.py set-siteconfig

When we wanted something like:

rb-site manage /var/www/reviewboard set-siteconfig

This change fixes that by ditching the execute_from_command_line()
wrapper function and instead creating a ManagementUtility directly,
where we set the correct program name in order to get the right command
in the standard manage.py --help list of commands. We then pass in
rb-site-manage as a placeholder program name, which gets replaced in a
monkey-patched parser wrapper.

This is, unfortunately, the only way to do that without outright
replacing Django management command infrastructure, but should be safe
to do.

Tested both rb-site manage /path/to/site -- --help and
rb-site manage /path/to/site <command> -- --help for several different
commands. Saw a useful "usage:" line in the help with the full command.

Summary ID
Monkey-patch the help text when showing management command help in rb-site.
When running `rb-site manage ... <command> --help`, we'd show the standard management command help text that Django displays. This would end up showing the wrong program invocation, which wasn't helpful. For instance: rbsite.py set-siteconfig When we wanted something like: rb-site manage /var/www/reviewboard set-siteconfig This change fixes that by ditching the `execute_from_command_line()` wrapper function and instead creating a `ManagementUtility` directly, where we set the correct program name in order to get the right command in the standard `manage.py --help` list of commands. We then pass in `rb-site-manage` as a placeholder program name, which gets replaced in a monkey-patched parser wrapper. This is, unfortunately, the only way to do that without outright replacing Django management command infrastructure, but should be safe to do.
270461c2be87a8e92e9d54acd344cbc09903f755
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (c064386)
Loading...