summaryrefslogtreecommitdiff
path: root/cmd2
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-26 23:43:29 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-26 23:43:29 -0500
commit4308f95352ed5f9eea9dfa07f514dfff3b87bc6b (patch)
treef79d11909a80c4a0c74a6c75831c5bc7b5e4b987 /cmd2
parent9d1c2f7379f1d38515d357c2a01a7f4b335da0af (diff)
downloadcmd2-git-4308f95352ed5f9eea9dfa07f514dfff3b87bc6b.tar.gz
Flushed out initialization documentation
Also: - Rearranged some instance attributes in Cmd class to make it clear that they were not used by tab-completion functions.
Diffstat (limited to 'cmd2')
-rw-r--r--cmd2/cmd2.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 900a2451..648aadb1 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -272,9 +272,6 @@ class Cmd(cmd.Cmd):
# Otherwise it will be None. Its used to know when a pipe process can be killed and/or waited upon.
self._cur_pipe_proc_reader = None
- # Used by complete() for readline tab completion
- self.completion_matches = []
-
# Used to keep track of whether we are redirecting or piping output
self._redirecting = False
@@ -321,6 +318,38 @@ class Cmd(cmd.Cmd):
elif transcript_files:
self._transcript_files = transcript_files
+ # Set the pager(s) for use with the ppaged() method for displaying output using a pager
+ if sys.platform.startswith('win'):
+ self.pager = self.pager_chop = 'more'
+ else:
+ # Here is the meaning of the various flags we are using with the less command:
+ # -S causes lines longer than the screen width to be chopped (truncated) rather than wrapped
+ # -R causes ANSI "style" escape sequences to be output in raw form (i.e. colors are displayed)
+ # -X disables sending the termcap initialization and deinitialization strings to the terminal
+ # -F causes less to automatically exit if the entire file can be displayed on the first screen
+ self.pager = 'less -RXF'
+ self.pager_chop = 'less -SRXF'
+
+ # This boolean flag determines whether or not the cmd2 application can interact with the clipboard
+ self._can_clip = can_clip
+
+ # This determines the value returned by cmdloop() when exiting the application
+ self.exit_code = 0
+
+ # This lock should be acquired before doing any asynchronous changes to the terminal to
+ # ensure the updates to the terminal don't interfere with the input being typed or output
+ # being printed by a command.
+ self.terminal_lock = threading.RLock()
+
+ # Commands that have been disabled from use. This is to support commands that are only available
+ # during specific states of the application. This dictionary's keys are the command names and its
+ # values are DisabledCommand objects.
+ self.disabled_commands = dict()
+
+ # If any command has been categorized, then all other commands that haven't been categorized
+ # will display under this section in the help output.
+ self.default_category = 'Uncategorized'
+
# The default key for sorting string results. Its default value performs a case-insensitive alphabetical sort.
# If natural sorting is preferred, then set this to NATURAL_SORT_KEY.
# cmd2 uses this key for sorting:
@@ -331,7 +360,7 @@ class Cmd(cmd.Cmd):
############################################################################################################
# The following variables are used by tab-completion functions. They are reset each time complete() is run
- # in reset_completion_defaults() and it is up to completer functions to set them before returning results.
+ # in _reset_completion_defaults() and it is up to completer functions to set them before returning results.
############################################################################################################
# If True and a single match is returned to complete(), then a space will be appended
@@ -345,6 +374,9 @@ class Cmd(cmd.Cmd):
# An optional header that prints above the tab-completion suggestions
self.completion_header = ''
+ # Used by complete() for readline tab completion
+ self.completion_matches = []
+
# Use this list if you are completing strings that contain a common delimiter and you only want to
# display the final portion of the matches as the tab-completion suggestions. The full matches
# still must be returned from your completer function. For an example, look at path_complete()
@@ -360,38 +392,6 @@ class Cmd(cmd.Cmd):
# If False, then complete() will sort the matches using self.default_sort_key before they are displayed.
self.matches_sorted = False
- # Set the pager(s) for use with the ppaged() method for displaying output using a pager
- if sys.platform.startswith('win'):
- self.pager = self.pager_chop = 'more'
- else:
- # Here is the meaning of the various flags we are using with the less command:
- # -S causes lines longer than the screen width to be chopped (truncated) rather than wrapped
- # -R causes ANSI "style" escape sequences to be output in raw form (i.e. colors are displayed)
- # -X disables sending the termcap initialization and deinitialization strings to the terminal
- # -F causes less to automatically exit if the entire file can be displayed on the first screen
- self.pager = 'less -RXF'
- self.pager_chop = 'less -SRXF'
-
- # This boolean flag determines whether or not the cmd2 application can interact with the clipboard
- self._can_clip = can_clip
-
- # This determines the value returned by cmdloop() when exiting the application
- self.exit_code = 0
-
- # This lock should be acquired before doing any asynchronous changes to the terminal to
- # ensure the updates to the terminal don't interfere with the input being typed or output
- # being printed by a command.
- self.terminal_lock = threading.RLock()
-
- # Commands that have been disabled from use. This is to support commands that are only available
- # during specific states of the application. This dictionary's keys are the command names and its
- # values are DisabledCommand objects.
- self.disabled_commands = dict()
-
- # If any command has been categorized, then all other commands that haven't been categorized
- # will display under this section in the help output.
- self.default_category = 'Uncategorized'
-
# ----- Methods related to presenting output to the user -----
@property