summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index 01270d12..564c1d3f 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1581,6 +1581,15 @@ class History(list):
return result
def search(self, target):
+ """ Search the history for a particular term.
+
+ :param target: str - term to search for
+ :return: List[str] - list of matches
+ """
+ # If there is no history yet, don't try to search through a non-existent list, just return an empty list
+ if len(self) < 1:
+ return []
+
target = target.strip()
if target[0] == target[-1] == '/' and len(target) > 1:
target = target[1:-1]
@@ -1858,4 +1867,5 @@ class CmdResult(namedtuple('CmdResult', ['out', 'err', 'war'])):
if __name__ == '__main__':
# If run as the main application, simply start a bare-bones cmd2 application with only built-in functionality.
app = Cmd()
+ app.debug = True
app.cmdloop()