From 858476599f1d8ac9642c36f0a573cbd596e47a67 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 18 Jul 2019 16:08:32 -0400 Subject: Renamed ArgParser to Cmd2ArgumentParser to make it clear it's a derived class of argparse.ArgumentParser when developers read the code in cmd2.py. --- examples/tab_autocompletion.py | 6 +++--- examples/table_display.py | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/tab_autocompletion.py b/examples/tab_autocompletion.py index 2e611b70..7ab827e5 100755 --- a/examples/tab_autocompletion.py +++ b/examples/tab_autocompletion.py @@ -8,7 +8,7 @@ import functools from typing import List import cmd2 -from cmd2 import utils, CompletionItem +from cmd2 import utils, Cmd2ArgumentParser, CompletionItem actors = ['Mark Hamill', 'Harrison Ford', 'Carrie Fisher', 'Alec Guinness', 'Peter Mayhew', 'Anthony Daniels', 'Adam Driver', 'Daisy Ridley', 'John Boyega', 'Oscar Isaac', @@ -128,7 +128,7 @@ class TabCompleteExample(cmd2.Cmd): suggest_description = "Suggest command demonstrates argparse customizations.\n" suggest_description += "See hybrid_suggest and orig_suggest to compare the help output." - suggest_parser = cmd2.ArgParser(description=suggest_description) + suggest_parser = Cmd2ArgumentParser(description=suggest_description) suggest_parser.add_argument('-t', '--type', choices=['movie', 'show'], required=True) suggest_parser.add_argument('-d', '--duration', nargs=(1, 2), action='append', @@ -204,7 +204,7 @@ class TabCompleteExample(cmd2.Cmd): '\n '.join(ep_list))) print() - video_parser = cmd2.ArgParser(prog='media') + video_parser = Cmd2ArgumentParser(prog='media') video_types_subparsers = video_parser.add_subparsers(title='Media Types', dest='type') diff --git a/examples/table_display.py b/examples/table_display.py index a5a5c830..a8fd2cb0 100755 --- a/examples/table_display.py +++ b/examples/table_display.py @@ -14,9 +14,11 @@ and either the colored or colorama module """ from typing import Tuple -import cmd2 import tableformatter as tf +import cmd2 +from cmd2 import Cmd2ArgumentParser + # Configure colors for when users chooses the "-c" flag to enable color in the table output try: from colored import bg @@ -142,14 +144,14 @@ def high_density_objs(row_obj: CityInfo) -> dict: return opts -def make_table_parser() -> cmd2.ArgParser: +def make_table_parser() -> Cmd2ArgumentParser: """Create a unique instance of an argparse Argument parser for processing table arguments. NOTE: The two cmd2 argparse decorators require that each parser be unique, even if they are essentially a deep copy of each other. For cases like that, you can create a function to return a unique instance of a parser, which is what is being done here. """ - table_parser = cmd2.ArgParser() + table_parser = Cmd2ArgumentParser() table_item_group = table_parser.add_mutually_exclusive_group() table_item_group.add_argument('-c', '--color', action='store_true', help='Enable color') table_item_group.add_argument('-f', '--fancy', action='store_true', help='Fancy Grid') -- cgit v1.2.1