Skip to content

Commit 0ee3d6b

Browse files
authored
Merge pull request #284 from python-cmd2/instance_variables
Converted a few class variables into instance variables
2 parents 27a8a15 + 91255cd commit 0ee3d6b

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

cmd2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,6 @@ class Cmd(cmd.Cmd):
803803
allow_cli_args = True # Should arguments passed on the command-line be processed as commands?
804804
allow_redirection = True # Should output redirection and pipes be allowed
805805
default_to_shell = False # Attempt to run unrecognized commands as shell commands
806-
excludeFromHistory = '''run ru r history histor histo hist his hi h edit edi ed e eof eo eos'''.split()
807-
exclude_from_help = ['do_eof', 'do_eos', 'do__relative_load'] # Commands to exclude from the help menu
808806
reserved_words = []
809807

810808
# Attributes which ARE dynamically settable at runtime
@@ -874,7 +872,12 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, persistent_histor
874872
# Call super class constructor. Need to do it in this way for Python 2 and 3 compatibility
875873
cmd.Cmd.__init__(self, completekey=completekey, stdin=stdin, stdout=stdout)
876874

875+
# Commands to exclude from the help menu or history command
876+
self.exclude_from_help = ['do_eof', 'do_eos', 'do__relative_load']
877+
self.excludeFromHistory = '''history histor histo hist his hi h edit edi ed e eof eo eos'''.split()
878+
877879
self._finalize_app_parameters()
880+
878881
self.initial_stdout = sys.stdout
879882
self.history = History()
880883
self.pystate = {}

tests/test_parsing.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def parser():
2727
c.multilineCommands = ['multiline']
2828
c.case_insensitive = True
2929
c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands,
30-
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
31-
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
32-
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
33-
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
30+
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
31+
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
32+
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
33+
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
3434
return c.parser_manager.main_parser
3535

3636
# Case-insensitive ParserManager
@@ -40,10 +40,10 @@ def ci_pm():
4040
c.multilineCommands = ['multiline']
4141
c.case_insensitive = True
4242
c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands,
43-
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
44-
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
45-
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
46-
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
43+
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
44+
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
45+
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
46+
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
4747
return c.parser_manager
4848

4949
# Case-sensitive ParserManager
@@ -53,10 +53,10 @@ def cs_pm():
5353
c.multilineCommands = ['multiline']
5454
c.case_insensitive = False
5555
c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands,
56-
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
57-
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
58-
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
59-
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
56+
legalChars=c.legalChars, commentGrammars=c.commentGrammars,
57+
commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive,
58+
blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser,
59+
preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts)
6060
return c.parser_manager
6161

6262

0 commit comments

Comments
 (0)