@@ -1315,36 +1315,16 @@ def do_set(self, arg):
1315
1315
def do_pause (self , text ):
1316
1316
"""Displays the specified text then waits for the user to press <Enter>.
1317
1317
1318
- Usage: pause [text]
1319
-
1320
- :param text: str - Text to display to the user (default: blank line)
1321
- """
1322
- sm .input (text + '\n ' )
1323
-
1324
- def help_pause (self ):
1325
- """Print help for do_pause()."""
1326
- help_str = """Displays the specified text then waits for the user to press <Enter>.
1327
-
1328
1318
Usage: pause [text]"""
1329
- self . stdout . write ( "{} \n " . format ( help_str ) )
1319
+ sm . input ( text + ' \n ' )
1330
1320
1331
1321
# noinspection PyMethodMayBeStatic
1332
1322
def do_shell (self , command ):
1333
1323
"""Execute a command as if at the OS prompt.
1334
1324
1335
- Usage: shell command
1336
-
1337
- :param command: str - shell command to execute
1338
- """
1325
+ Usage: shell <command> [arguments]"""
1339
1326
os .system (command )
1340
1327
1341
- def help_shell (self ):
1342
- """Print help for do_shell()."""
1343
- help_str = """Execute a command as if at the OS prompt.
1344
-
1345
- Usage: shell cmd"""
1346
- self .stdout .write ("{}\n " .format (help_str ))
1347
-
1348
1328
def path_complete (self , text , line , begidx , endidx , dir_exe_only = False , dir_only = False ):
1349
1329
"""Method called to complete an input line by local file system path completion.
1350
1330
@@ -1710,23 +1690,20 @@ def _last_matching(self, arg):
1710
1690
def do_edit (self , arg ):
1711
1691
"""Edit a file or command in a text editor.
1712
1692
1713
- Usage: edit [N]|[file_path]
1714
-
1715
- :param arg: str - [N]|[file_path]
1693
+ Usage: edit [N]|[file_path]
1716
1694
1717
- * **N** - Number of command (from history), or `*` for all commands in history (default: most recent command)
1718
- * ** file_path** - path to a file to open in editor
1695
+ * N - Number of command (from history), or `*` for all commands in history (default: last command)
1696
+ * file_path - path to a file to open in editor
1719
1697
1720
- The editor used is determined by the ``editor`` settable parameter.
1721
- "set editor (program-name)" to change or set the EDITOR environment variable.
1698
+ The editor used is determined by the ``editor`` settable parameter.
1699
+ "set editor (program-name)" to change or set the EDITOR environment variable.
1722
1700
1723
- The optional arguments are mutually exclusive. Either a command number OR a file name can be supplied.
1724
- If neither is supplied, the most recent command in the history is edited.
1701
+ The optional arguments are mutually exclusive. Either a command number OR a file name can be supplied.
1702
+ If neither is supplied, the most recent command in the history is edited.
1725
1703
1726
- Edited commands are always run after the editor is closed.
1704
+ Edited commands are always run after the editor is closed.
1727
1705
1728
- Edited files are run on close if the ``autorun_on_edit`` settable parameter is True.
1729
- """
1706
+ Edited files are run on close if the ``autorun_on_edit`` settable parameter is True."""
1730
1707
if not self .editor :
1731
1708
raise EnvironmentError ("Please use 'set editor' to specify your text editing program of choice." )
1732
1709
filename = self .default_file_name
@@ -1749,41 +1726,17 @@ def do_edit(self, arg):
1749
1726
if self .autorun_on_edit or buffer :
1750
1727
self .do_load (filename )
1751
1728
1752
- def help_edit (self ):
1753
- """Print help for do_edit()."""
1754
- help_str = """Edit a file or command in a text editor.
1755
-
1756
- Usage: edit [N]|[file_path]
1757
-
1758
- optional arguments:
1759
- N Number of command (from history), or `*` for all commands in history (default: most recent command)
1760
- file_path path to a file to open in editor
1761
-
1762
- The editor used is determined by the `editor` settable parameter.
1763
- "set editor (program-name" to change or set the EDITOR environment variable.
1764
-
1765
- The optional arguments are mutually exclusive. Either a command number OR a file name can be supplied.
1766
- If neither is supplied, the most recent command in the history is edited.
1767
-
1768
- Edited commands are always run after the editor is closed.
1769
-
1770
- Edited files are run on close if the `autorun_on_edit` settable parameter is True."""
1771
- self .stdout .write ("{}\n " .format (help_str ))
1772
-
1773
1729
saveparser = (pyparsing .Optional (pyparsing .Word (pyparsing .nums ) ^ '*' )("idx" ) +
1774
1730
pyparsing .Optional (pyparsing .Word (legalChars + '/\\ ' ))("fname" ) +
1775
1731
pyparsing .stringEnd )
1776
1732
1777
1733
def do_save (self , arg ):
1778
1734
"""Saves command(s) from history to file.
1779
1735
1780
- Usage: save [N] [file_path]
1781
-
1782
- :param arg: str - [N] [filepath]
1736
+ Usage: save [N] [file_path]
1783
1737
1784
- * **N** - Number of command (from history), or `*` for all commands in history (default: most recent command)
1785
- * **file_path** - location to save script of command(s) to (default: value stored in ``default_file_name``)
1786
- """
1738
+ * N - Number of command (from history), or `*` for all commands in history (default: last command)
1739
+ * file_path - location to save script of command(s) to (default: value stored in `default_file_name` param)"""
1787
1740
try :
1788
1741
args = self .saveparser .parseString (arg )
1789
1742
except pyparsing .ParseException :
@@ -1806,17 +1759,6 @@ def do_save(self, arg):
1806
1759
self .perror ('Error saving {}' .format (fname ))
1807
1760
raise
1808
1761
1809
- def help_save (self ):
1810
- """Print help for do_save()."""
1811
- help_str = """Saves command(s) from history to file.
1812
-
1813
- Usage: save [N] [file_path]
1814
-
1815
- optional arguments:
1816
- N - Number of command (from history), or `*` for all commands in history (default: most recent command)
1817
- file_path - location to save script of command(s) to (default: value stored in `default_file_name` parameter)"""
1818
- self .stdout .write ("{}\n " .format (help_str ))
1819
-
1820
1762
def _read_file_or_url (self , fname ):
1821
1763
"""Open a file or URL for reading by the do_load() method.
1822
1764
@@ -1871,12 +1813,11 @@ def do__relative_load(self, arg=None):
1871
1813
def do_load (self , file_path = None ):
1872
1814
"""Runs commands in script at file or URL.
1873
1815
1874
- Usage: load [file_path]
1816
+ Usage: load [file_path]
1875
1817
1876
- :param file_path: str - a file path or URL pointing to a script (default: value stored in ``default_file_name``)
1877
- :return: bool - True implies application should stop, False to continue like normal
1818
+ * file_path - a file path or URL pointing to a script (default: value stored in `default_file_name` param)
1878
1819
1879
- Script should contain one command per line, just like command would be typed in console.
1820
+ Script should contain one command per line, just like command would be typed in console.
1880
1821
"""
1881
1822
# If arg is None or arg is an empty string, use the default filename
1882
1823
if not file_path :
@@ -1901,42 +1842,17 @@ def do_load(self, file_path=None):
1901
1842
self .lastcmd = ''
1902
1843
return stop and (stop != self ._STOP_SCRIPT_NO_EXIT )
1903
1844
1904
- def help_load (self ):
1905
- """Print help for do_load()."""
1906
- help_str = """Runs commands in script at file or URL.
1907
-
1908
- Usage: load [file_path]
1909
-
1910
- optional argument:
1911
- file_path - a file path or URL pointing to a script (default: value stored in `default_file_name` parameter)
1912
-
1913
- Script should contain one command per line, just like command would be typed in console."""
1914
- self .stdout .write ("{}\n " .format (help_str ))
1915
-
1916
1845
def do_run (self , arg ):
1917
1846
"""run [arg]: re-runs an earlier command
1918
1847
1919
- :param arg: str - determines which command is re-run, as follows:
1920
-
1921
- * no arg -> run most recent command
1922
- * arg is integer -> run one history item, by index
1923
- * arg is string -> run most recent command by string search
1924
- * arg is /enclosed in forward-slashes/ -> run most recent by regex
1925
- """
1926
- runme = self ._last_matching (arg )
1927
- self .pfeedback (runme )
1928
- if runme :
1929
- return self .onecmd_plus_hooks (runme )
1930
-
1931
- def help_run (self ):
1932
- """Print help for do_run()."""
1933
- help_str = """run [arg]: re-runs an earlier command
1934
-
1935
1848
no arg -> run most recent command
1936
1849
arg is integer -> run one history item, by index
1937
1850
arg is string -> run most recent command by string search
1938
1851
arg is /enclosed in forward-slashes/ -> run most recent by regex"""
1939
- self .stdout .write ("{}\n " .format (help_str ))
1852
+ runme = self ._last_matching (arg )
1853
+ self .pfeedback (runme )
1854
+ if runme :
1855
+ return self .onecmd_plus_hooks (runme )
1940
1856
1941
1857
def run_transcript_tests (self , callargs ):
1942
1858
"""Runs transcript tests for provided file(s).
0 commit comments