Opened 8 years ago

Closed 6 years ago

#9158 closed (fixed)

django-admin.py print help to stderr

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: Core (Management commands) Version: 1.0
Severity: Keywords:
Cc: Dario Ocles Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Command django-admin.py help print this text to stdout:

Usage: django-admin.py subcommand [options] [args]

Options:
  --settings=SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath=PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Print traceback on exception
  --version             show program's version number and exit
  -h, --help            show this help message and exit

and this text to stderr:

Type 'django-admin.py help <subcommand>' for help on a specific subcommand.

Available subcommands:
  cleanup
  compilemessages
  createcachetable
  dbshell
  diffsettings
  dumpdata
  flush
  inspectdb
  loaddata
  makemessages
  reset
  runfcgi
  runserver
  shell
  sql
  sqlall
  sqlclear
  sqlcustom
  sqlflush
  sqlindexes
  sqlinitialdata
  sqlreset
  sqlsequencereset
  startapp
  startproject
  syncdb
  test
  testserver
  validate

It is quite illogical. And it is not possible to do something as it:

django-admin.py help | grep sql

(It is also useful if there are some custom commands with common prefix and I want their list.)

Attached patch replaces all four occurrences in django.core.management.init from stderr to stdout. But the first and the second are real errors, patch with only the third and the fourth change could be better.

Attachments (3)

django-admin-stdout.diff (1.6 KB) - added by Petr Marhoun <petr.marhoun@…> 8 years ago.
django-admin-stdout2011.diff (1.4 KB) - added by Dario Ocles 6 years ago.
The patch was outdated. I updated this to the latest version.
django-admin-stdout_with_test.diff (2.2 KB) - added by Dario Ocles 6 years ago.
Print just help info to stdout, print real errors to stderr. Fixed tests

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by Petr Marhoun <petr.marhoun@…>

Attachment: django-admin-stdout.diff added

comment:1 Changed 8 years ago by Eric Holscher

Triage Stage: UnreviewedAccepted

Changed 6 years ago by Dario Ocles

The patch was outdated. I updated this to the latest version.

comment:2 Changed 6 years ago by Dario Ocles

Cc: Dario Ocles added

comment:3 Changed 6 years ago by Ramiro Morales

Patch needs improvement: set

Changed 6 years ago by Dario Ocles

Print just help info to stdout, print real errors to stderr. Fixed tests

comment:4 Changed 6 years ago by Dario Ocles

Patch needs improvement: unset

comment:5 Changed 6 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

In [15921]:

Fixed #9158 -- Changed django-admin.py help to be printed to stdout instead of stderr, so that it's more easily greppable. Thanks, petr.marhoun@…

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