summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-26 13:56:33 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2021-03-26 15:24:34 -0400
commit62ed8aebf6eefcf68a15fdd4b7a7cd5dfe4c6f6b (patch)
tree1e72725041a8e3f83f31dddbfd564fcd02f27401 /examples
parent070262e1f397e2297cdb1ad611db6b6d5bed8830 (diff)
downloadcmd2-git-py_refactor.tar.gz
Renamed use_ipython keyword parameter of cmd2.Cmd.__init__() to include_ipy.py_refactor
Added include_py keyword parameter to cmd2.Cmd.__init__(). If False, then the py command will not be available. Removed ability to run Python commands from the command line with py. Made banners and exit messages of Python and IPython consistent. Changed utils.is_text_file() to raise OSError if file cannot be read.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/arg_decorators.py2
-rwxr-xr-xexamples/basic.py2
-rwxr-xr-xexamples/cmd_as_argument.py4
-rwxr-xr-xexamples/colors.py4
-rwxr-xr-xexamples/decorator_example.py5
-rwxr-xr-xexamples/dynamic_commands.py2
-rwxr-xr-xexamples/hello_cmd2.py5
-rwxr-xr-xexamples/help_categories.py3
-rwxr-xr-xexamples/initialization.py2
-rwxr-xr-xexamples/override_parser.py2
-rwxr-xr-xexamples/plumbum_colors.py4
-rwxr-xr-xexamples/python_scripting.py4
12 files changed, 17 insertions, 22 deletions
diff --git a/examples/arg_decorators.py b/examples/arg_decorators.py
index a0d08d43..8785fe4f 100755
--- a/examples/arg_decorators.py
+++ b/examples/arg_decorators.py
@@ -9,7 +9,7 @@ import cmd2
class ArgparsingApp(cmd2.Cmd):
def __init__(self):
- super().__init__(use_ipython=True)
+ super().__init__(include_ipy=True)
self.intro = 'cmd2 has awesome decorators to make it easy to use Argparse to parse command arguments'
# do_fsize parser
diff --git a/examples/basic.py b/examples/basic.py
index 24e6b7d8..8f507e03 100755
--- a/examples/basic.py
+++ b/examples/basic.py
@@ -24,7 +24,7 @@ class BasicApp(cmd2.Cmd):
multiline_commands=['echo'],
persistent_history_file='cmd2_history.dat',
startup_script='scripts/startup.txt',
- use_ipython=True,
+ include_ipy=True,
)
self.intro = style('Welcome to PyOhio 2019 and cmd2!', fg=fg.red, bg=bg.white, bold=True) + ' 😀'
diff --git a/examples/cmd_as_argument.py b/examples/cmd_as_argument.py
index 33ad699b..39332203 100755
--- a/examples/cmd_as_argument.py
+++ b/examples/cmd_as_argument.py
@@ -30,8 +30,8 @@ class CmdLineApp(cmd2.Cmd):
def __init__(self):
shortcuts = dict(cmd2.DEFAULT_SHORTCUTS)
shortcuts.update({'&': 'speak'})
- # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(allow_cli_args=False, use_ipython=True, multiline_commands=['orate'], shortcuts=shortcuts)
+ # Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell
+ super().__init__(allow_cli_args=False, include_ipy=True, multiline_commands=['orate'], shortcuts=shortcuts)
self.self_in_py = True
self.maxrepeats = 3
diff --git a/examples/colors.py b/examples/colors.py
index 8246c18a..50c9b906 100755
--- a/examples/colors.py
+++ b/examples/colors.py
@@ -44,8 +44,8 @@ class CmdLineApp(cmd2.Cmd):
"""Example cmd2 application demonstrating colorized output."""
def __init__(self):
- # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(use_ipython=True)
+ # Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell
+ super().__init__(include_ipy=True)
self.maxrepeats = 3
# Make maxrepeats settable at runtime
diff --git a/examples/decorator_example.py b/examples/decorator_example.py
index 9497bcc0..6a5e6b10 100755
--- a/examples/decorator_example.py
+++ b/examples/decorator_example.py
@@ -24,10 +24,7 @@ class CmdLineApp(cmd2.Cmd):
def __init__(self, ip_addr=None, port=None, transcript_files=None):
shortcuts = dict(cmd2.DEFAULT_SHORTCUTS)
shortcuts.update({'&': 'speak'})
- # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(
- use_ipython=False, transcript_files=transcript_files, multiline_commands=['orate'], shortcuts=shortcuts
- )
+ super().__init__(transcript_files=transcript_files, multiline_commands=['orate'], shortcuts=shortcuts)
self.maxrepeats = 3
# Make maxrepeats settable at runtime
diff --git a/examples/dynamic_commands.py b/examples/dynamic_commands.py
index aca370ec..eee5b8cc 100755
--- a/examples/dynamic_commands.py
+++ b/examples/dynamic_commands.py
@@ -33,7 +33,7 @@ class CommandsInLoop(cmd2.Cmd):
help_func_name = HELP_FUNC_PREFIX + command
setattr(self, help_func_name, help_func)
- super().__init__(use_ipython=True)
+ super().__init__(include_ipy=True)
def send_text(self, args: cmd2.Statement, *, text: str):
"""Simulate sending text to a server and printing the response."""
diff --git a/examples/hello_cmd2.py b/examples/hello_cmd2.py
index e94ad2a5..0e639e29 100755
--- a/examples/hello_cmd2.py
+++ b/examples/hello_cmd2.py
@@ -11,9 +11,8 @@ if __name__ == '__main__':
import sys
# If run as the main application, simply start a bare-bones cmd2 application with only built-in functionality.
- # Set "use_ipython" to True to include the ipy command if IPython is installed, which supports advanced interactive
- # debugging of your application via introspection on self.
- app = cmd2.Cmd(use_ipython=True, persistent_history_file='cmd2_history.dat')
+ # Enable commands to support interactive Python and IPython shells.
+ app = cmd2.Cmd(include_py=True, include_ipy=True, persistent_history_file='cmd2_history.dat')
app.self_in_py = True # Enable access to "self" within the py command
app.debug = True # Show traceback if/when an exception occurs
sys.exit(app.cmdloop())
diff --git a/examples/help_categories.py b/examples/help_categories.py
index d9a7cce2..80c976c1 100755
--- a/examples/help_categories.py
+++ b/examples/help_categories.py
@@ -33,8 +33,7 @@ class HelpCategories(cmd2.Cmd):
CMD_CAT_SERVER_INFO = 'Server Information'
def __init__(self):
- # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(use_ipython=False)
+ super().__init__()
def do_connect(self, _):
"""Connect command"""
diff --git a/examples/initialization.py b/examples/initialization.py
index 54bef6d8..dfea2183 100755
--- a/examples/initialization.py
+++ b/examples/initialization.py
@@ -28,7 +28,7 @@ class BasicApp(cmd2.Cmd):
multiline_commands=['echo'],
persistent_history_file='cmd2_history.dat',
startup_script='scripts/startup.txt',
- use_ipython=True,
+ include_ipy=True,
)
# Prints an intro banner once upon application startup
diff --git a/examples/override_parser.py b/examples/override_parser.py
index f615e6e0..00161ef6 100755
--- a/examples/override_parser.py
+++ b/examples/override_parser.py
@@ -23,7 +23,7 @@ argparse.cmd2_parser_module = 'examples.custom_parser'
if __name__ == '__main__':
import sys
- app = cmd2.Cmd(use_ipython=True, persistent_history_file='cmd2_history.dat')
+ app = cmd2.Cmd(include_ipy=True, persistent_history_file='cmd2_history.dat')
app.self_in_py = True # Enable access to "self" within the py command
app.debug = True # Show traceback if/when an exception occurs
sys.exit(app.cmdloop())
diff --git a/examples/plumbum_colors.py b/examples/plumbum_colors.py
index 16326569..d138c433 100755
--- a/examples/plumbum_colors.py
+++ b/examples/plumbum_colors.py
@@ -78,8 +78,8 @@ class CmdLineApp(cmd2.Cmd):
"""Example cmd2 application demonstrating colorized output."""
def __init__(self):
- # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(use_ipython=True)
+ # Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell
+ super().__init__(include_ipy=True)
self.maxrepeats = 3
# Make maxrepeats settable at runtime
diff --git a/examples/python_scripting.py b/examples/python_scripting.py
index bb43095e..33d8010d 100755
--- a/examples/python_scripting.py
+++ b/examples/python_scripting.py
@@ -33,8 +33,8 @@ class CmdLineApp(cmd2.Cmd):
""" Example cmd2 application to showcase conditional control flow in Python scripting within cmd2 apps."""
def __init__(self):
- # Enable the optional ipy command if IPython is installed by setting use_ipython=True
- super().__init__(use_ipython=True)
+ # Set include_ipy to True to enable the "ipy" command which runs an interactive IPython shell
+ super().__init__(include_ipy=True)
self._set_prompt()
self.intro = 'Happy 𝛑 Day. Note the full Unicode support: 😇 💩'