summaryrefslogtreecommitdiff
path: root/docs/source/interactive_mode.rst
blob: 519e89a6a106a842f3a5aaf87a5c4c97a6124b1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
==================
 Interactive Mode
==================

In addition to running single commands from the command line, cliff
supports an interactive mode in which the user is presented with a
separate command shell. All of the command plugins available from the
command line are automatically configured as commands within the
shell.

Refer to the cmd2_ documentation for more details about features of
the shell.

.. _cmd2: http://packages.python.org/cmd2/index.html

.. todo:: Add details about configuring and interacting with the shell (copy from cmd2 docs)

Example
=======

The ``cliffdemo`` application enters interactive mode if no command is
specified on the command line.

::

    (.venv)$ cliffdemo
    (cliffdemo) help
    
    Shell commands (type help <topic>):
    ===================================
    cmdenvironment  edit  hi       l   list  pause  r    save  shell      show
    ed              help  history  li  load  py     run  set   shortcuts
    
    Undocumented commands:
    ======================
    EOF  eof  exit  q  quit
    
    Application commands (type help <topic>):
    =========================================
    files  help  simple  file  error  two part

To obtain instructions for a built-in or application command, use the
``help`` command:

::
    
    (cliffdemo) help simple
    usage: simple [-h]
    
    A simple command that prints a message.
    
    optional arguments:
      -h, --help  show this help message and exit

The commands can be run, including options and arguments, as on the
regular command line:

::
    
    (cliffdemo) simple
    sending greeting
    hi!
    (cliffdemo) files
    +----------------------+-------+
    |         Name         |  Size |
    +----------------------+-------+
    | .git                 |   578 |
    | .gitignore           |   268 |
    | .tox                 |   238 |
    | .venv                |   204 |
    | announce.rst         |  1015 |
    | announce.rst~        |   708 |
    | cliff                |   884 |
    | cliff.egg-info       |   340 |
    | cliffdemo.log        |  2193 |
    | cliffdemo.log.1      | 10225 |
    | demoapp              |   408 |
    | dist                 |   136 |
    | distribute_setup.py  | 15285 |
    | distribute_setup.pyc | 15196 |
    | docs                 |   238 |
    | LICENSE              | 11358 |
    | Makefile             |   376 |
    | Makefile~            |    94 |
    | MANIFEST.in          |   186 |
    | MANIFEST.in~         |   344 |
    | README.rst           |  1063 |
    | setup.py             |  5855 |
    | setup.py~            |  8128 |
    | tests                |   204 |
    | tox.ini              |    76 |
    | tox.ini~             |   421 |
    +----------------------+-------+
    (cliffdemo)