314
|
1 ===================================
|
|
2 Features requiring no modifications
|
|
3 ===================================
|
|
4
|
|
5 These features are provided "for free" to a cmd_-based application
|
|
6 simply by replacing ``import cmd`` with ``import cmd2 as cmd``.
|
|
7
|
315
|
8 Script files
|
|
9 ============
|
|
10
|
|
11 Commands can be loaded from, run from, and saved to text files.
|
|
12
|
|
13 .. automethod:: cmd2.Cmd.do_load
|
|
14
|
|
15 Output redirection
|
|
16 ==================
|
|
17
|
324
|
18 As in a Unix shell, output of a command can be redirected:
|
|
19
|
|
20 - sent to a file with ``>``, as in ``mycommand args > filename.txt``
|
|
21 - piped (``|``) as input to operating-system commands, as in
|
|
22 ``mycommand args | wc``
|
|
23 - sent to the paste buffer, ready for the next Copy operation, by
|
|
24 ending with a bare ``>``, as in ``mycommand args >``.. Redirecting
|
|
25 to paste buffer requires software to be installed on the operating
|
|
26 system, pywin32_ on Windows or xclip_ on *nix.
|
|
27
|
|
28 .. _pywin32:: http://sourceforge.net/projects/pywin32/
|
|
29 .. _xclip:: http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/
|
|
30
|
|
31
|
|
32 operating-system programs, like
|
|
33
|
315
|
34 Commands at start
|
|
35 =================
|
|
36
|
|
37 Python
|
|
38 ======
|
|
39
|
314
|
40 Searchable command history
|
|
41 ==========================
|
|
42
|
|
43 All cmd_-based applications have access to previous commands with
|
|
44 the up- and down- cursor keys.
|
|
45
|
|
46 All cmd_-based applications on systems with the ``readline`` module
|
|
47 also provide `bash-like history list editing`_.
|
|
48
|
|
49 .. _`bash-like history list editing`: http://www.talug.org/events/20030709/cmdline_history.html
|
|
50
|
|
51 ``cmd2`` makes a third type of history access available, consisting of these commands:
|
|
52
|
|
53 .. automethod:: cmd2.Cmd.do_history
|
|
54
|
315
|
55 Transcript-based testing
|
|
56 ========================
|