summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/argparse_completion.py19
-rwxr-xr-xexamples/async_printing.py9
-rwxr-xr-xexamples/basic.py6
-rwxr-xr-xexamples/basic_completion.py4
-rwxr-xr-xexamples/colors.py14
-rw-r--r--examples/custom_parser.py6
-rwxr-xr-xexamples/decorator_example.py4
-rw-r--r--examples/default_categories.py5
-rwxr-xr-xexamples/dynamic_commands.py5
-rwxr-xr-xexamples/exit_code.py4
-rwxr-xr-xexamples/hello_cmd2.py4
-rwxr-xr-xexamples/help_categories.py4
-rwxr-xr-xexamples/hooks.py4
-rwxr-xr-xexamples/initialization.py6
-rw-r--r--examples/modular_commands/commandset_basic.py18
-rw-r--r--examples/modular_commands/commandset_complex.py8
-rw-r--r--examples/modular_commands/commandset_custominit.py7
-rw-r--r--examples/modular_commands_basic.py5
-rw-r--r--examples/modular_commands_dynamic.py8
-rw-r--r--examples/modular_commands_main.py34
-rw-r--r--examples/modular_subcommands.py8
-rwxr-xr-xexamples/override_parser.py4
-rwxr-xr-xexamples/paged_output.py4
-rwxr-xr-xexamples/pirate.py4
-rwxr-xr-xexamples/plumbum_colors.py9
-rwxr-xr-xexamples/python_scripting.py4
-rw-r--r--examples/scripts/save_help_text.py5
-rwxr-xr-xexamples/table_creation.py19
28 files changed, 183 insertions, 48 deletions
diff --git a/examples/argparse_completion.py b/examples/argparse_completion.py
index e44533b3..bd36db29 100644
--- a/examples/argparse_completion.py
+++ b/examples/argparse_completion.py
@@ -4,10 +4,21 @@
A simple example demonstrating how to integrate tab completion with argparse-based commands.
"""
import argparse
-from typing import Dict, List
-
-from cmd2 import Cmd, Cmd2ArgumentParser, CompletionItem, with_argparser
-from cmd2.utils import CompletionError, basic_complete
+from typing import (
+ Dict,
+ List,
+)
+
+from cmd2 import (
+ Cmd,
+ Cmd2ArgumentParser,
+ CompletionItem,
+ with_argparser,
+)
+from cmd2.utils import (
+ CompletionError,
+ basic_complete,
+)
# Data source for argparse.choices
food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato']
diff --git a/examples/async_printing.py b/examples/async_printing.py
index a136d8e2..a4e02c92 100755
--- a/examples/async_printing.py
+++ b/examples/async_printing.py
@@ -7,10 +7,15 @@ and changes the window title
import random
import threading
import time
-from typing import List
+from typing import (
+ List,
+)
import cmd2
-from cmd2 import fg, style
+from cmd2 import (
+ fg,
+ style,
+)
ALERTS = ["Watch as this application prints alerts and updates the prompt",
"This will only happen when the prompt is present",
diff --git a/examples/basic.py b/examples/basic.py
index 2a1e9a12..800a0946 100755
--- a/examples/basic.py
+++ b/examples/basic.py
@@ -9,7 +9,11 @@
6) Shell-like capabilities
"""
import cmd2
-from cmd2 import bg, fg, style
+from cmd2 import (
+ bg,
+ fg,
+ style,
+)
class BasicApp(cmd2.Cmd):
diff --git a/examples/basic_completion.py b/examples/basic_completion.py
index f33029c9..83e71a50 100755
--- a/examples/basic_completion.py
+++ b/examples/basic_completion.py
@@ -13,7 +13,9 @@ familiar with argparse. The recommended approach for tab completing positional t
argparse-based completion. For an example integrating tab completion with argparse, see argparse_completion.py
"""
import functools
-from typing import List
+from typing import (
+ List,
+)
import cmd2
diff --git a/examples/colors.py b/examples/colors.py
index 8f8e3c6e..dc5bdb99 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -24,12 +24,20 @@ Always
regardless of the output destination
"""
import argparse
-from typing import Any
+from typing import (
+ Any,
+)
-from colorama import Back, Fore, Style
+from colorama import (
+ Back,
+ Fore,
+ Style,
+)
import cmd2
-from cmd2 import ansi
+from cmd2 import (
+ ansi,
+)
class CmdLineApp(cmd2.Cmd):
diff --git a/examples/custom_parser.py b/examples/custom_parser.py
index 34c7bee2..194b47b8 100644
--- a/examples/custom_parser.py
+++ b/examples/custom_parser.py
@@ -4,7 +4,11 @@ Defines the CustomParser used with override_parser.py example
"""
import sys
-from cmd2 import Cmd2ArgumentParser, ansi, set_default_argument_parser
+from cmd2 import (
+ Cmd2ArgumentParser,
+ ansi,
+ set_default_argument_parser,
+)
# First define the parser
diff --git a/examples/decorator_example.py b/examples/decorator_example.py
index 1b6d7570..29fcbd9e 100755
--- a/examples/decorator_example.py
+++ b/examples/decorator_example.py
@@ -11,7 +11,9 @@ all the commands in the transcript against decorator_example.py,
verifying that the output produced matches the transcript.
"""
import argparse
-from typing import List
+from typing import (
+ List,
+)
import cmd2
diff --git a/examples/default_categories.py b/examples/default_categories.py
index 19699513..efa6729d 100644
--- a/examples/default_categories.py
+++ b/examples/default_categories.py
@@ -5,7 +5,10 @@ Simple example demonstrating basic CommandSet usage.
"""
import cmd2
-from cmd2 import CommandSet, with_default_category
+from cmd2 import (
+ CommandSet,
+ with_default_category,
+)
@with_default_category('Default Category')
diff --git a/examples/dynamic_commands.py b/examples/dynamic_commands.py
index 620acb7f..35c2cd42 100755
--- a/examples/dynamic_commands.py
+++ b/examples/dynamic_commands.py
@@ -5,7 +5,10 @@
import functools
import cmd2
-from cmd2.constants import COMMAND_FUNC_PREFIX, HELP_FUNC_PREFIX
+from cmd2.constants import (
+ COMMAND_FUNC_PREFIX,
+ HELP_FUNC_PREFIX,
+)
COMMAND_LIST = ['foo', 'bar']
CATEGORY = 'Dynamic Commands'
diff --git a/examples/exit_code.py b/examples/exit_code.py
index 89ed86cd..062ee12d 100755
--- a/examples/exit_code.py
+++ b/examples/exit_code.py
@@ -2,7 +2,9 @@
# coding=utf-8
"""A simple example demonstrating the following how to emit a non-zero exit code in your cmd2 application.
"""
-from typing import List
+from typing import (
+ List,
+)
import cmd2
diff --git a/examples/hello_cmd2.py b/examples/hello_cmd2.py
index 94ec334f..06303722 100755
--- a/examples/hello_cmd2.py
+++ b/examples/hello_cmd2.py
@@ -3,7 +3,9 @@
"""
This is intended to be a completely bare-bones cmd2 application suitable for rapid testing and debugging.
"""
-from cmd2 import cmd2
+from cmd2 import (
+ cmd2,
+)
if __name__ == '__main__':
import sys
diff --git a/examples/help_categories.py b/examples/help_categories.py
index 7401bafe..0b25375a 100755
--- a/examples/help_categories.py
+++ b/examples/help_categories.py
@@ -8,7 +8,9 @@ It also demonstrates the effects of decorator order when it comes to argparse er
import functools
import cmd2
-from cmd2 import COMMAND_NAME
+from cmd2 import (
+ COMMAND_NAME,
+)
def my_decorator(f):
diff --git a/examples/hooks.py b/examples/hooks.py
index f8079e58..8acbf91b 100755
--- a/examples/hooks.py
+++ b/examples/hooks.py
@@ -10,7 +10,9 @@ follow a command without any intervening whitespace.
"""
import re
-from typing import List
+from typing import (
+ List,
+)
import cmd2
diff --git a/examples/initialization.py b/examples/initialization.py
index 50bb73aa..76a136dd 100755
--- a/examples/initialization.py
+++ b/examples/initialization.py
@@ -13,7 +13,11 @@
10) How to make custom attributes settable at runtime
"""
import cmd2
-from cmd2 import bg, fg, style
+from cmd2 import (
+ bg,
+ fg,
+ style,
+)
class BasicApp(cmd2.Cmd):
diff --git a/examples/modular_commands/commandset_basic.py b/examples/modular_commands/commandset_basic.py
index 2ceda439..4417bfe5 100644
--- a/examples/modular_commands/commandset_basic.py
+++ b/examples/modular_commands/commandset_basic.py
@@ -2,10 +2,20 @@
"""
A simple example demonstrating a loadable command set
"""
-from typing import List
-
-from cmd2 import Cmd, CommandSet, Statement, with_category, with_default_category
-from cmd2.utils import CompletionError
+from typing import (
+ List,
+)
+
+from cmd2 import (
+ Cmd,
+ CommandSet,
+ Statement,
+ with_category,
+ with_default_category,
+)
+from cmd2.utils import (
+ CompletionError,
+)
@with_default_category('Basic Completion')
diff --git a/examples/modular_commands/commandset_complex.py b/examples/modular_commands/commandset_complex.py
index 579c0677..4905265a 100644
--- a/examples/modular_commands/commandset_complex.py
+++ b/examples/modular_commands/commandset_complex.py
@@ -5,10 +5,14 @@ Test CommandSet
"""
import argparse
-from typing import List
+from typing import (
+ List,
+)
import cmd2
-from cmd2 import utils
+from cmd2 import (
+ utils,
+)
@cmd2.with_default_category('Fruits')
diff --git a/examples/modular_commands/commandset_custominit.py b/examples/modular_commands/commandset_custominit.py
index 2ef94a75..e24ac291 100644
--- a/examples/modular_commands/commandset_custominit.py
+++ b/examples/modular_commands/commandset_custominit.py
@@ -2,7 +2,12 @@
"""
A simple example demonstrating a loadable command set
"""
-from cmd2 import Cmd, CommandSet, Statement, with_default_category
+from cmd2 import (
+ Cmd,
+ CommandSet,
+ Statement,
+ with_default_category,
+)
@with_default_category('Custom Init')
diff --git a/examples/modular_commands_basic.py b/examples/modular_commands_basic.py
index b9d4c4a2..4d5f83ce 100644
--- a/examples/modular_commands_basic.py
+++ b/examples/modular_commands_basic.py
@@ -5,7 +5,10 @@ Simple example demonstrating basic CommandSet usage.
"""
import cmd2
-from cmd2 import CommandSet, with_default_category
+from cmd2 import (
+ CommandSet,
+ with_default_category,
+)
@with_default_category('My Category')
diff --git a/examples/modular_commands_dynamic.py b/examples/modular_commands_dynamic.py
index b2be5dd1..8264c068 100644
--- a/examples/modular_commands_dynamic.py
+++ b/examples/modular_commands_dynamic.py
@@ -10,8 +10,14 @@ on which CommandSets are loaded
"""
import argparse
+
import cmd2
-from cmd2 import CommandSet, with_argparser, with_category, with_default_category
+from cmd2 import (
+ CommandSet,
+ with_argparser,
+ with_category,
+ with_default_category,
+)
@with_default_category('Fruits')
diff --git a/examples/modular_commands_main.py b/examples/modular_commands_main.py
index b698e00f..2c652f22 100644
--- a/examples/modular_commands_main.py
+++ b/examples/modular_commands_main.py
@@ -5,13 +5,33 @@ A complex example demonstrating a variety of methods to load CommandSets using a
with examples of how to integrate tab completion with argparse-based commands.
"""
import argparse
-from typing import Dict, Iterable, List, Optional
-
-from cmd2 import Cmd, Cmd2ArgumentParser, CommandSet, CompletionItem, with_argparser
-from cmd2.utils import CompletionError, basic_complete
-from modular_commands.commandset_basic import BasicCompletionCommandSet # noqa: F401
-from modular_commands.commandset_complex import CommandSetA # noqa: F401
-from modular_commands.commandset_custominit import CustomInitCommandSet # noqa: F401
+from typing import (
+ Dict,
+ Iterable,
+ List,
+ Optional,
+)
+
+from cmd2 import (
+ Cmd,
+ Cmd2ArgumentParser,
+ CommandSet,
+ CompletionItem,
+ with_argparser,
+)
+from cmd2.utils import (
+ CompletionError,
+ basic_complete,
+)
+from modular_commands.commandset_basic import ( # noqa: F401
+ BasicCompletionCommandSet,
+)
+from modular_commands.commandset_complex import ( # noqa: F401
+ CommandSetA,
+)
+from modular_commands.commandset_custominit import (
+ CustomInitCommandSet, # noqa: F401
+)
# Data source for argparse.choices
food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato']
diff --git a/examples/modular_subcommands.py b/examples/modular_subcommands.py
index c1d499f0..082903fb 100644
--- a/examples/modular_subcommands.py
+++ b/examples/modular_subcommands.py
@@ -11,8 +11,14 @@ The `load` and `unload` command will load and unload the CommandSets. The availa
subcommands to the `cut` command will change depending on which CommandSets are loaded.
"""
import argparse
+
import cmd2
-from cmd2 import CommandSet, with_argparser, with_category, with_default_category
+from cmd2 import (
+ CommandSet,
+ with_argparser,
+ with_category,
+ with_default_category,
+)
@with_default_category('Fruits')
diff --git a/examples/override_parser.py b/examples/override_parser.py
index b6548388..b723f6d7 100755
--- a/examples/override_parser.py
+++ b/examples/override_parser.py
@@ -13,7 +13,9 @@ import argparse
# Next import stuff from cmd2. It will import your module just before the cmd2.Cmd class file is imported
# and therefore override the parser class it uses on its commands.
-from cmd2 import cmd2
+from cmd2 import (
+ cmd2,
+)
argparse.cmd2_parser_module = 'examples.custom_parser'
diff --git a/examples/paged_output.py b/examples/paged_output.py
index cba5c7c5..191fdd7f 100755
--- a/examples/paged_output.py
+++ b/examples/paged_output.py
@@ -3,7 +3,9 @@
"""A simple example demonstrating the using paged output via the ppaged() method.
"""
import os
-from typing import List
+from typing import (
+ List,
+)
import cmd2
diff --git a/examples/pirate.py b/examples/pirate.py
index a50f9a51..ab2403be 100755
--- a/examples/pirate.py
+++ b/examples/pirate.py
@@ -10,7 +10,9 @@ import argparse
import cmd2
import cmd2.ansi
-from cmd2.constants import MULTILINE_TERMINATOR
+from cmd2.constants import (
+ MULTILINE_TERMINATOR,
+)
class Pirate(cmd2.Cmd):
diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py
index a30e4c70..ec138e89 100755
--- a/examples/plumbum_colors.py
+++ b/examples/plumbum_colors.py
@@ -28,8 +28,13 @@ WARNING: This example requires the plumbum package, which isn't normally require
import argparse
import cmd2
-from cmd2 import ansi
-from plumbum.colors import bg, fg
+from cmd2 import (
+ ansi,
+)
+from plumbum.colors import (
+ bg,
+ fg,
+)
class FgColors(ansi.ColorBase):
diff --git a/examples/python_scripting.py b/examples/python_scripting.py
index 6e4295d4..5d3f43b3 100755
--- a/examples/python_scripting.py
+++ b/examples/python_scripting.py
@@ -24,7 +24,9 @@ import argparse
import os
import cmd2
-from cmd2 import ansi
+from cmd2 import (
+ ansi,
+)
class CmdLineApp(cmd2.Cmd):
diff --git a/examples/scripts/save_help_text.py b/examples/scripts/save_help_text.py
index cc4cfcc7..ad028395 100644
--- a/examples/scripts/save_help_text.py
+++ b/examples/scripts/save_help_text.py
@@ -8,7 +8,10 @@ This is meant to be run within a cmd2 session using run_pyscript.
import argparse
import os
import sys
-from typing import List, TextIO
+from typing import (
+ List,
+ TextIO,
+)
ASTERISKS = "********************************************************"
diff --git a/examples/table_creation.py b/examples/table_creation.py
index 6325b200..a290f5df 100755
--- a/examples/table_creation.py
+++ b/examples/table_creation.py
@@ -3,10 +3,21 @@
"""Examples of using the cmd2 table creation API"""
import functools
import sys
-from typing import Any, List
-
-from cmd2 import ansi
-from cmd2.table_creator import AlternatingTable, BorderedTable, Column, HorizontalAlignment, SimpleTable
+from typing import (
+ Any,
+ List,
+)
+
+from cmd2 import (
+ ansi,
+)
+from cmd2.table_creator import (
+ AlternatingTable,
+ BorderedTable,
+ Column,
+ HorizontalAlignment,
+ SimpleTable,
+)
class DollarFormatter: