Skip to content

Commit

Permalink
refactor: add the explicit REPL command search
Browse files Browse the repository at this point in the history
Adds ability to search the command keywords in the dictionaries.
  • Loading branch information
hrishikeshrt committed Mar 17, 2022
1 parent 45400a5 commit 55176e8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pycdsl/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,17 @@ def do_version(self, text: str = None):

# ----------------------------------------------------------------------- #

def default(self, line: str):
def do_search(self, line: str):
"""
Search in the active dictionaries
Note
----
* Searching in the active dictionaries is also the default action.
* In general, we do not need to use this command explicitly unless we
want to search the command keywords, such as, `available` `search`,
`version`, `help` etc. in the active dictionaries.
"""
if self.active_dicts is None:
self.logger.error("Please select a dictionary first.")
else:
Expand All @@ -324,6 +334,13 @@ def default(self, line: str):
)
)

# ----------------------------------------------------------------------- #

def default(self, line: str):
self.do_search(line)

# ----------------------------------------------------------------------- #

def cmdloop(self, intro: str = None):
print(self.intro)
print(self.desc)
Expand Down

0 comments on commit 55176e8

Please sign in to comment.