diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-04-24 21:15:34 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-04-24 21:21:35 -0400 |
commit | 9b78cf4913202995dcf065ecf5077bf16fa01f95 (patch) | |
tree | a04ca95d6f67bae491f290cc71036d2a4f6b168c /examples | |
parent | 9c7bbfa5bdbf8c8d81c0cd3c3cd5179d700de0b2 (diff) | |
download | cmd2-git-9b78cf4913202995dcf065ecf5077bf16fa01f95.tar.gz |
Added info on semantic versioning and branching strategy to CONTRIBUTING.md
Also:
- Added isort to Pipenv dev
- Added setup.cfg to make it easy to run flake8, doc8, and isort directly from the command line without using invoke
- Ran isort to sort includes
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/alias_startup.py | 1 | ||||
-rw-r--r-- | examples/argparse_completion.py | 4 | ||||
-rwxr-xr-x | examples/async_printing.py | 2 | ||||
-rwxr-xr-x | examples/basic.py | 2 | ||||
-rwxr-xr-x | examples/colors.py | 3 | ||||
-rw-r--r-- | examples/custom_parser.py | 3 | ||||
-rwxr-xr-x | examples/exit_code.py | 3 | ||||
-rwxr-xr-x | examples/hooks.py | 1 | ||||
-rwxr-xr-x | examples/initialization.py | 2 | ||||
-rwxr-xr-x | examples/migrating.py | 3 | ||||
-rwxr-xr-x | examples/override_parser.py | 4 | ||||
-rwxr-xr-x | examples/plumbum_colors.py | 3 | ||||
-rwxr-xr-x | examples/scripts/arg_printer.py | 1 | ||||
-rwxr-xr-x | examples/subcommands.py | 1 | ||||
-rwxr-xr-x | examples/unicode_commands.py | 1 |
15 files changed, 20 insertions, 14 deletions
diff --git a/examples/alias_startup.py b/examples/alias_startup.py index 052d1367..3fa9ec5a 100755 --- a/examples/alias_startup.py +++ b/examples/alias_startup.py @@ -5,6 +5,7 @@ 2) How to run an initialization script at startup """ import os + import cmd2 diff --git a/examples/argparse_completion.py b/examples/argparse_completion.py index bf2b2723..e44533b3 100644 --- a/examples/argparse_completion.py +++ b/examples/argparse_completion.py @@ -6,8 +6,8 @@ A simple example demonstrating how to integrate tab completion with argparse-bas import argparse from typing import Dict, List -from cmd2 import Cmd, Cmd2ArgumentParser, with_argparser, CompletionItem -from cmd2.utils import basic_complete, CompletionError +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 692ce769..a136d8e2 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -10,7 +10,7 @@ import time from typing import List import cmd2 -from cmd2 import style, fg +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 5df3d1b5..2a1e9a12 100755 --- a/examples/basic.py +++ b/examples/basic.py @@ -9,7 +9,7 @@ 6) Shell-like capabilities """ import cmd2 -from cmd2 import style, fg, bg +from cmd2 import bg, fg, style class BasicApp(cmd2.Cmd): diff --git a/examples/colors.py b/examples/colors.py index 1466471b..8f8e3c6e 100755 --- a/examples/colors.py +++ b/examples/colors.py @@ -26,9 +26,10 @@ Always import argparse from typing import Any +from colorama import Back, Fore, Style + import cmd2 from cmd2 import ansi -from colorama import Fore, Back, Style class CmdLineApp(cmd2.Cmd): diff --git a/examples/custom_parser.py b/examples/custom_parser.py index 7c154176..34c7bee2 100644 --- a/examples/custom_parser.py +++ b/examples/custom_parser.py @@ -4,8 +4,7 @@ Defines the CustomParser used with override_parser.py example """ import sys -from cmd2 import Cmd2ArgumentParser, set_default_argument_parser -from cmd2 import ansi +from cmd2 import Cmd2ArgumentParser, ansi, set_default_argument_parser # First define the parser diff --git a/examples/exit_code.py b/examples/exit_code.py index f4b19091..89ed86cd 100755 --- a/examples/exit_code.py +++ b/examples/exit_code.py @@ -2,9 +2,10 @@ # coding=utf-8 """A simple example demonstrating the following how to emit a non-zero exit code in your cmd2 application. """ -import cmd2 from typing import List +import cmd2 + class ReplWithExitCode(cmd2.Cmd): """ Example cmd2 application where we can specify an exit code when existing.""" diff --git a/examples/hooks.py b/examples/hooks.py index 409c8979..f8079e58 100755 --- a/examples/hooks.py +++ b/examples/hooks.py @@ -10,7 +10,6 @@ follow a command without any intervening whitespace. """ import re - from typing import List import cmd2 diff --git a/examples/initialization.py b/examples/initialization.py index 609255f1..50bb73aa 100755 --- a/examples/initialization.py +++ b/examples/initialization.py @@ -13,7 +13,7 @@ 10) How to make custom attributes settable at runtime """ import cmd2 -from cmd2 import style, fg, bg +from cmd2 import bg, fg, style class BasicApp(cmd2.Cmd): diff --git a/examples/migrating.py b/examples/migrating.py index 3a25b8c8..86a59ed6 100755 --- a/examples/migrating.py +++ b/examples/migrating.py @@ -3,9 +3,8 @@ """ A sample application for cmd which can be used to show how to migrate to cmd2. """ -import random - import cmd +import random class CmdLineApp(cmd.Cmd): diff --git a/examples/override_parser.py b/examples/override_parser.py index eecb0e88..b6548388 100755 --- a/examples/override_parser.py +++ b/examples/override_parser.py @@ -10,12 +10,14 @@ The following code shows how to override it with your own parser class. # See the code for custom_parser.py. It simply defines a parser and calls cmd2.set_default_argument_parser() # with the custom parser's type. import argparse -argparse.cmd2_parser_module = 'examples.custom_parser' # 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 +argparse.cmd2_parser_module = 'examples.custom_parser' + + if __name__ == '__main__': import sys app = cmd2.Cmd(use_ipython=True, persistent_history_file='cmd2_history.dat') diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py index 2887ef1f..ed65f245 100755 --- a/examples/plumbum_colors.py +++ b/examples/plumbum_colors.py @@ -27,9 +27,10 @@ WARNING: This example requires the plumbum package, which isn't normally require """ import argparse +from plumbum.colors import bg, fg + import cmd2 from cmd2 import ansi -from plumbum.colors import fg, bg class FgColors(ansi.ColorBase): diff --git a/examples/scripts/arg_printer.py b/examples/scripts/arg_printer.py index 19f6dd3f..f5f30c6d 100755 --- a/examples/scripts/arg_printer.py +++ b/examples/scripts/arg_printer.py @@ -2,6 +2,7 @@ # coding=utf-8 import os import sys + print("Running Python script {!r} which was called with {} arguments".format(os.path.basename(sys.argv[0]), len(sys.argv) - 1)) for i, arg in enumerate(sys.argv[1:]): diff --git a/examples/subcommands.py b/examples/subcommands.py index 4f569b1e..dd69d97e 100755 --- a/examples/subcommands.py +++ b/examples/subcommands.py @@ -7,6 +7,7 @@ This example shows an easy way for a single command to have many subcommands, ea and provides separate contextual help. """ import argparse + import cmd2 sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football', 'Space Ball'] diff --git a/examples/unicode_commands.py b/examples/unicode_commands.py index f8381e50..0a7c5ac7 100755 --- a/examples/unicode_commands.py +++ b/examples/unicode_commands.py @@ -3,6 +3,7 @@ """A simple example demonstrating support for unicode command names. """ import math + import cmd2 |