File: single_command_tool.rst

package info (click to toggle)
python-cleo 2.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,120 kB
  • sloc: python: 8,293; makefile: 22; sh: 2
file content (18 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Building a Single Command Application
#####################################

When building a command line tool, you may not need to provide several commands.
In such case, having to pass the command name each time is tedious. Fortunately,
it is possible to remove this need by using `default()` when adding a command:

.. code-block:: python

    from cleo import Application

    command = GreetCommand()

    app = Application()
    app.add(command.default())

    # this now executes the 'GreetCommand' without passing its name
    app.run()