Opened 10 years ago
Closed 10 years ago
#12127 closed enhancement (fixed)
Document htpasswd.py
| 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: | 
           
  | 
      ||
| 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?
Attachments (0)
Change History (6)
comment:1 by , 10 years ago
comment:2 by , 10 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(): 107 107 help. 108 108 """ 109 109 sys.stderr.write("Syntax error: " + msg) 110 sys.stderr.write(parser.get_usage())110 parser.print_help(file=sys.stderr) 111 111 sys.exit(1) 112 112 113 113 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 , 10 years ago
| Milestone: | 1.0.8 → 1.0.9 | 
|---|
comment:4 by , 10 years ago
| Keywords: | htdigest added | 
|---|---|
| Owner: | set to | 
| Status: | new → assigned | 
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, 46 46 parser.add_option('-b', action='store_true', dest='batch', default=False, 47 47 help='Batch mode, password on the commandline.') 48 48 49 if len(sys.argv) <= 1: 50 parser.print_help(file=sys.stderr) 51 sys.exit(1) 52 49 53 opts, args = parser.parse_args() 50 54 51 55 try:  - 
      
contrib/htpasswd.py
diff --git a/contrib/htpasswd.py b/contrib/htpasswd.py index 4d545ebe3..166dbd7ac 100755
a b def main(): 100 100 parser.add_option('-D', action='store_true', dest='delete_user', 101 101 default=False, help='Remove the given user from the password file.') 102 102 103 if len(sys.argv) <= 1: 104 parser.print_help(file=sys.stderr) 105 sys.exit(1) 103 106 options, args = parser.parse_args() 104 107 105 108 def syntax_error(msg):  
comment:5 by , 10 years ago
| Milestone: | 1.0.9 → 1.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 , 10 years ago
| Release Notes: | modified (diff) | 
|---|---|
| Resolution: | → fixed | 
| Status: | assigned → closed | 



  
Ah, passing
--helpis required to see the description of the option (but not the "usage"):Maybe that should also be printed even when no arguments are given?