Edgewall Software

Opened 9 years ago

Closed 8 years ago

#12127 closed enhancement (fixed)

Document htpasswd.py — at Version 6

Reported by: anonymous Owned by: Jun Omae
Priority: normal Milestone: 1.0.10
Component: contrib Version:
Severity: normal Keywords: htpasswd htdigest
Cc: Branch:
Release Notes:

htdigest.py and htpasswd.py print help messages with no arguments.

API Changes:
Internal Changes:

Description

Trac docs mention:

$ ./contrib/htpasswd.py -cb htpasswd user1 user1
$ ./contrib/htpasswd.py -b htpasswd user2 user2

What's the difference between -cb and -b?

Running the script:

Usage:
        htpasswd.py [-c] filename username
        htpasswd.py -b[c] filename username password
        htpasswd.py -D filename username

What do -c, b[c] or -D mean?

Change History (6)

comment:1 by anonymous, 9 years ago

Ah, passing --help is required to see the description of the option (but not the "usage"):

Options:
  -h, --help  show this help message and exit
  -b          Batch mode; password is passed on the command line IN THE CLEAR.
  -c          Create a new htpasswd file, overwriting any existing file.
  -D          Remove the given user from the password file.

Maybe that should also be printed even when no arguments are given?

comment:2 by Jun Omae, 9 years ago

Milestone: 1.0.8

Okay. We should print help with no arguments.

  • contrib/htpasswd.py

    diff --git a/contrib/htpasswd.py b/contrib/htpasswd.py
    index 4d545ebe3..dfc814886 100755
    a b def main():  
    107107        help.
    108108        """
    109109        sys.stderr.write("Syntax error: " + msg)
    110         sys.stderr.write(parser.get_usage())
     110        parser.print_help(file=sys.stderr)
    111111        sys.exit(1)
    112112
    113113    if not (options.batch or options.delete_user):

Before the patch:

$ PYTHONPATH=. ~/venv/py27-1.0/bin/python contrib/htpasswd.py
Syntax error: Only batch and delete modes are supported
Usage:
        htpasswd.py -b[c] filename username password
        htpasswd.py -D filename username

After the patch:

$ PYTHONPATH=. ~/venv/py27-1.0/bin/python contrib/htpasswd.py
Syntax error: Only batch and delete modes are supported
Usage:
        htpasswd.py -b[c] filename username password
        htpasswd.py -D filename username

Options:
  -h, --help  show this help message and exit
  -b          Batch mode; password is passed on the command line IN THE CLEAR.
  -c          Create a new htpasswd file, overwriting any existing file.
  -D          Remove the given user from the password file.

comment:3 by Ryan J Ollos, 9 years ago

Milestone: 1.0.81.0.9

comment:4 by Jun Omae, 9 years ago

Keywords: htdigest added
Owner: set to Jun Omae
Status: newassigned

It would be good to prevent Syntax error message and show help only when no arguments. contrib/htdigest.py has the same issue.

  • contrib/htdigest.py

    diff --git a/contrib/htdigest.py b/contrib/htdigest.py
    index 9fe36ce8f..3cbe1b153 100755
    a b parser.add_option('-c', action='store_true', dest='create', default=False,  
    4646parser.add_option('-b', action='store_true', dest='batch', default=False,
    4747                  help='Batch mode, password on the commandline.')
    4848
     49if len(sys.argv) <= 1:
     50    parser.print_help(file=sys.stderr)
     51    sys.exit(1)
     52
    4953opts, args = parser.parse_args()
    5054
    5155try:
  • contrib/htpasswd.py

    diff --git a/contrib/htpasswd.py b/contrib/htpasswd.py
    index 4d545ebe3..166dbd7ac 100755
    a b def main():  
    100100    parser.add_option('-D', action='store_true', dest='delete_user',
    101101        default=False, help='Remove the given user from the password file.')
    102102
     103    if len(sys.argv) <= 1:
     104        parser.print_help(file=sys.stderr)
     105        sys.exit(1)
    103106    options, args = parser.parse_args()
    104107
    105108    def syntax_error(msg):

comment:5 by Ryan J Ollos, 9 years ago

Milestone: 1.0.91.0.10

Moving tickets that appear to be uncompleted for milestone:1.0.9. Please move back to milestone:1.0.9 if the ticket can be completed by 2015-09-07 18:00 UTC.

comment:6 by Jun Omae, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [14439] and merged to trunk in [14440].

Note: See TracTickets for help on using tickets.