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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
Using Console Commands, Shortcuts and Built-in Commands
#######################################################
In addition to the options you specify for your commands, there are some
built-in options as well as a couple of built-in commands for Cleo.
.. note::
These examples assume you have added a file ``application.py`` to run at
the cli:
.. code-block:: python
#!/usr/bin/env python
# application.py
from cleo import Application
application = Application()
# ...
if __name__ == '__main__':
application.run()
Built-in Commands
=================
The help command lists the help information for the specified command. For
example, to get the help for the ``list`` command:
.. code-block:: bash
$ python application.py help list
Running ``help`` without specifying a command will list the global options:
.. code-block:: bash
$ python application.py help
Global Options
==============
You can get help information for any command with the ``--help`` option. To
get help for the ``greet`` command:
.. code-block:: bash
$ python application.py greet --help
$ python application.py greet -h
You can suppress output with:
.. code-block:: bash
$ python application.py greet --quiet
$ python application.py greet -q
You can get more verbose messages (if this is supported for a command)
with:
.. code-block:: bash
$ python application.py greet --verbose
$ python application.py greet -v
If you need more verbose output, use `-vv` or `-vvv`
.. code-block:: bash
$ python application.py greet -vv
$ python application.py greet -vvv
If you set the optional arguments to give your application a name and version:
.. code-block:: python
application = Application('console', '1.2')
then you can use:
.. code-block:: bash
$ python application.py --version
$ python application.py -V
to get this information output:
.. code-block:: text
Console version 1.2
If you do not provide both arguments then it will just output:
.. code-block:: text
console tool
You can force turning on ANSI output coloring with:
.. code-block:: bash
$ python application.py greet --ansi
or turn it off with:
.. code-block:: bash
$ python application.py greet --no-ansi
You can suppress any interactive questions from the command you are running with:
.. code-block:: bash
$ python application.py greet --no-interaction
$ python application.py greet -n
Shortcut Syntax
===============
You do not have to type out the full command names. You can just type the
shortest unambiguous name to run a command. So if there are non-clashing
commands, then you can run ``help`` like this:
.. code-block:: bash
$ python application.py h
|