diff options
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 648aadb1..f3b7c4a4 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -181,28 +181,23 @@ class Cmd(cmd.Cmd): super().__init__(completekey=completekey, stdin=stdin, stdout=stdout) # Attributes which should NOT be dynamically settable via the set command at runtime - # To prevent a user from altering these with the py/ipy commands, remove locals_in_py from the - # settable dictionary during your applications's __init__ method. self.default_to_shell = False # Attempt to run unrecognized commands as shell commands self.quit_on_sigint = False # Quit the loop on interrupt instead of just resetting prompt self.allow_redirection = allow_redirection # Security setting to prevent redirection of stdout # Attributes which ARE dynamically settable via the set command at runtime - self.continuation_prompt = '> ' self.debug = False self.echo = False self.editor = Cmd.DEFAULT_EDITOR self.feedback_to_output = False # Do not include nonessentials in >, | output by default (things like timing) - self.locals_in_py = False + self.quiet = False # Do not suppress nonessential output + self.timing = False # Prints elapsed time for each command # The maximum number of CompletionItems to display during tab completion. If the number of completion # suggestions exceeds this number, they will be displayed in the typical columnized format and will # not include the description value of the CompletionItems. self.max_completion_items = 50 - self.quiet = False # Do not suppress nonessential output - self.timing = False # Prints elapsed time for each command - # To make an attribute settable with the "do_set" command, add it to this ... self.settable = \ { @@ -211,18 +206,21 @@ class Cmd(cmd.Cmd): '(valid values: {}, {}, {})'.format(ansi.STYLE_TERMINAL, ansi.STYLE_ALWAYS, ansi.STYLE_NEVER)), - 'continuation_prompt': 'On 2nd+ line of input', 'debug': 'Show full error stack on error', 'echo': 'Echo command issued into output', 'editor': 'Program used by ``edit``', 'feedback_to_output': 'Include nonessentials in `|`, `>` results', - 'locals_in_py': 'Allow access to your application in py via self', 'max_completion_items': 'Maximum number of CompletionItems to display during tab completion', - 'prompt': 'The prompt issued to solicit input', 'quiet': "Don't print nonessential feedback", 'timing': 'Report execution times' } + # Use as prompt for multiline commands on the 2nd+ line of input + self.continuation_prompt = '> ' + + # Allow access to your application in embedded Python shells and scripts py via self + self.self_in_py = False + # Commands to exclude from the help menu and tab completion self.hidden_commands = ['eof', '_relative_load', '_relative_run_script'] @@ -3118,7 +3116,7 @@ class Cmd(cmd.Cmd): self.py_locals['quit'] = py_quit self.py_locals['exit'] = py_quit - if self.locals_in_py: + if self.self_in_py: self.py_locals['self'] = self elif 'self' in self.py_locals: del self.py_locals['self'] @@ -3238,7 +3236,7 @@ class Cmd(cmd.Cmd): exec("{} = py_bridge".format(cmd2_app.py_bridge_name)) # Add self variable pointing to cmd2_app, if allowed - if cmd2_app.locals_in_py: + if cmd2_app.self_in_py: exec("self = cmd2_app") # Delete these names from the environment so IPython can't use them |