From dae4f2f5ccae0768d2fb38a4b9524fa467857353 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 4 Jul 2019 16:03:58 -0400 Subject: Fixing some examples --- examples/hooks.py | 5 ----- examples/table_display.py | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/hooks.py b/examples/hooks.py index 39a7a0d5..acd427cd 100755 --- a/examples/hooks.py +++ b/examples/hooks.py @@ -38,11 +38,6 @@ class CmdLineApp(cmd2.Cmd): # Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist # default_to_shell = True def __init__(self, *args, **kwargs): - # sneakily remove the cmd2.Cmd command called run_script - # this lets a user enter a command like "l5" and allows it to - # be unambiguous - delattr(cmd2.Cmd, "do_run_script") - super().__init__(*args, **kwargs) # register three hooks diff --git a/examples/table_display.py b/examples/table_display.py index cedd2ca0..54d5b7a4 100755 --- a/examples/table_display.py +++ b/examples/table_display.py @@ -15,6 +15,7 @@ and either the colored or colorama module from typing import Tuple import cmd2 +from cmd2.argparse_custom import Cmd2ArgParser import tableformatter as tf # Configure colors for when users chooses the "-c" flag to enable color in the table output @@ -142,14 +143,14 @@ def high_density_objs(row_obj: CityInfo) -> dict: return opts -def make_table_parser() -> cmd2.argparse_completer.ACArgumentParser: +def make_table_parser() -> Cmd2ArgParser: """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.argparse_completer.ACArgumentParser() + table_parser = Cmd2ArgParser() 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 From 42bf56f8334cddc0fe3423e98eba5dbc537a4dd8 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Thu, 4 Jul 2019 16:13:43 -0400 Subject: Reverting changes that should have been made on a different branch --- examples/table_display.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/table_display.py b/examples/table_display.py index 54d5b7a4..cedd2ca0 100755 --- a/examples/table_display.py +++ b/examples/table_display.py @@ -15,7 +15,6 @@ and either the colored or colorama module from typing import Tuple import cmd2 -from cmd2.argparse_custom import Cmd2ArgParser import tableformatter as tf # Configure colors for when users chooses the "-c" flag to enable color in the table output @@ -143,14 +142,14 @@ def high_density_objs(row_obj: CityInfo) -> dict: return opts -def make_table_parser() -> Cmd2ArgParser: +def make_table_parser() -> cmd2.argparse_completer.ACArgumentParser: """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 = Cmd2ArgParser() + table_parser = cmd2.argparse_completer.ACArgumentParser() 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