diff options
| author | Steve Piercy <web@stevepiercy.com> | 2016-11-28 02:15:11 -0800 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2016-12-13 17:30:52 -0800 |
| commit | 7dd4214cccdc417d78a78391cf387ff62489beb0 (patch) | |
| tree | a236d9605e9958b46dcf8d3de4e05b30efbfebb6 | |
| parent | 5ad647c869c90a6a64fb557d6a28b0d09d7e7354 (diff) | |
| download | pyramid-7dd4214cccdc417d78a78391cf387ff62489beb0.tar.gz pyramid-7dd4214cccdc417d78a78391cf387ff62489beb0.tar.bz2 pyramid-7dd4214cccdc417d78a78391cf387ff62489beb0.zip | |
use argparse and autoprogram for ptweens
| -rw-r--r-- | docs/pscripts/ptweens.rst | 8 | ||||
| -rw-r--r-- | pyramid/scripts/ptweens.py | 12 |
2 files changed, 9 insertions, 11 deletions
diff --git a/docs/pscripts/ptweens.rst b/docs/pscripts/ptweens.rst index 02e23e49a..f586e1467 100644 --- a/docs/pscripts/ptweens.rst +++ b/docs/pscripts/ptweens.rst @@ -3,11 +3,7 @@ .. _ptweens_script: -``ptweens`` ------------ - -.. program-output:: ptweens --help - :prompt: - :shell: +.. autoprogram:: pyramid.scripts.ptweens:PTweensCommand.parser + :prog: ptweens .. seealso:: :ref:`displaying_tweens` diff --git a/pyramid/scripts/ptweens.py b/pyramid/scripts/ptweens.py index a7aa009da..3f8c9871e 100644 --- a/pyramid/scripts/ptweens.py +++ b/pyramid/scripts/ptweens.py @@ -1,4 +1,4 @@ -import optparse +import argparse import sys import textwrap @@ -14,7 +14,6 @@ def main(argv=sys.argv, quiet=False): return command.run() class PTweensCommand(object): - usage = '%prog config_uri' description = """\ Print all implicit and explicit tween objects used by a Pyramid application. The handler output includes whether the system is using an @@ -28,17 +27,20 @@ class PTweensCommand(object): will be assumed. Example: "ptweens myapp.ini#main". """ - parser = optparse.OptionParser( - usage, + parser = argparse.ArgumentParser( + usage="%(prog)s config_uri", description=textwrap.dedent(description), ) + parser.add_argument('config_uri', + help='The URI to the configuration file.') + stdout = sys.stdout bootstrap = (bootstrap,) # testing def __init__(self, argv, quiet=False): self.quiet = quiet - self.options, self.args = self.parser.parse_args(argv[1:]) + self.args = self.parser.parse_args(argv[1:]) def _get_tweens(self, registry): from pyramid.config import Configurator |
