@@ -1327,6 +1327,38 @@ def help_shell(self):
1327
1327
Usage: shell cmd"""
1328
1328
self .stdout .write ("{}\n " .format (help_str ))
1329
1329
1330
+ @staticmethod
1331
+ def path_complete (line ):
1332
+ """Method called to complete an input line by local file system path completion.
1333
+
1334
+ :param line: str - the current input line with leading whitespace removed
1335
+ :return: List[str] - a list of possible tab completions
1336
+ """
1337
+ path = line .split ()[- 1 ]
1338
+ if not path :
1339
+ path = '.'
1340
+
1341
+ dirname , rest = os .path .split (path )
1342
+ real_dir = os .path .expanduser (dirname )
1343
+
1344
+ path_completions = glob .glob (os .path .join (real_dir , rest ) + '*' )
1345
+
1346
+ # Strip off everything but the final part of the completion
1347
+ completions = [os .path .basename (c ) for c in path_completions ]
1348
+ return completions
1349
+
1350
+ # noinspection PyUnusedLocal
1351
+ def complete_shell (self , text , line , begidx , endidx ):
1352
+ """Handles completion of arguments for the shell command.
1353
+
1354
+ :param text: str - the string prefix we are attempting to match (all returned matches must begin with it)
1355
+ :param line: str - the current input line with leading whitespace removed
1356
+ :param begidx: str - the beginning indexe of the prefix text
1357
+ :param endidx: str - the ending index of the prefix text
1358
+ :return: List[str] - a list of possible tab completions
1359
+ """
1360
+ return self .path_complete (line )
1361
+
1330
1362
def do_py (self , arg ):
1331
1363
"""
1332
1364
py <command>: Executes a Python command.
@@ -1551,6 +1583,18 @@ def help_edit(self):
1551
1583
pyparsing .Optional (pyparsing .Word (legalChars + '/\\ ' ))("fname" ) +
1552
1584
pyparsing .stringEnd )
1553
1585
1586
+ # noinspection PyUnusedLocal
1587
+ def complete_edit (self , text , line , begidx , endidx ):
1588
+ """Handles completion of arguments for the edit command.
1589
+
1590
+ :param text: str - the string prefix we are attempting to match (all returned matches must begin with it)
1591
+ :param line: str - the current input line with leading whitespace removed
1592
+ :param begidx: str - the beginning indexe of the prefix text
1593
+ :param endidx: str - the ending index of the prefix text
1594
+ :return: List[str] - a list of possible tab completions
1595
+ """
1596
+ return self .path_complete (line )
1597
+
1554
1598
def do_save (self , arg ):
1555
1599
"""Saves command(s) from history to file.
1556
1600
@@ -1688,6 +1732,18 @@ def help_load(self):
1688
1732
Script should contain one command per line, just like command would be typed in console."""
1689
1733
self .stdout .write ("{}\n " .format (help_str ))
1690
1734
1735
+ # noinspection PyUnusedLocal
1736
+ def complete_load (self , text , line , begidx , endidx ):
1737
+ """Handles completion of arguments for the load command.
1738
+
1739
+ :param text: str - the string prefix we are attempting to match (all returned matches must begin with it)
1740
+ :param line: str - the current input line with leading whitespace removed
1741
+ :param begidx: str - the beginning indexe of the prefix text
1742
+ :param endidx: str - the ending index of the prefix text
1743
+ :return: List[str] - a list of possible tab completions
1744
+ """
1745
+ return self .path_complete (line )
1746
+
1691
1747
def do_run (self , arg ):
1692
1748
"""run [arg]: re-runs an earlier command
1693
1749
0 commit comments