diff options
| author | Steve Piercy <web@stevepiercy.com> | 2016-11-28 02:17:45 -0800 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2016-12-13 17:30:52 -0800 |
| commit | 812bc62a37205353de1d1719b82718dd0699bf1a (patch) | |
| tree | 268a3a099979f861a1194ef205d95d293ef2eafe | |
| parent | 7dd4214cccdc417d78a78391cf387ff62489beb0 (diff) | |
| download | pyramid-812bc62a37205353de1d1719b82718dd0699bf1a.tar.gz pyramid-812bc62a37205353de1d1719b82718dd0699bf1a.tar.bz2 pyramid-812bc62a37205353de1d1719b82718dd0699bf1a.zip | |
use argparse and autoprogram for ptviews
| -rw-r--r-- | docs/pscripts/pviews.rst | 8 | ||||
| -rw-r--r-- | pyramid/scripts/pviews.py | 12 |
2 files changed, 9 insertions, 11 deletions
diff --git a/docs/pscripts/pviews.rst b/docs/pscripts/pviews.rst index b4de5c054..da4660779 100644 --- a/docs/pscripts/pviews.rst +++ b/docs/pscripts/pviews.rst @@ -3,11 +3,7 @@ .. _pviews_script: -``pviews`` ----------- - -.. program-output:: pviews --help - :prompt: - :shell: +.. autoprogram:: pyramid.scripts.pviews:PViewsCommand.parser + :prog: pviews .. seealso:: :ref:`displaying_matching_views` diff --git a/pyramid/scripts/pviews.py b/pyramid/scripts/pviews.py index 9018eddb4..81150a801 100644 --- a/pyramid/scripts/pviews.py +++ b/pyramid/scripts/pviews.py @@ -1,4 +1,4 @@ -import optparse +import argparse import sys import textwrap @@ -13,7 +13,6 @@ def main(argv=sys.argv, quiet=False): return command.run() class PViewsCommand(object): - usage = '%prog config_uri url' description = """\ Print, for a given URL, the views that might match. Underneath each potentially matching route, list the predicates required. Underneath @@ -28,16 +27,19 @@ class PViewsCommand(object): """ stdout = sys.stdout - parser = optparse.OptionParser( - usage, + parser = argparse.ArgumentParser( + usage="%(prog)s config_uri url", description=textwrap.dedent(description) ) + parser.add_argument('config_uri', + help='The URI to the configuration file.') + 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 out(self, msg): # pragma: no cover if not self.quiet: |
