def cmd(func):
    """Specifies that ``func`` returns a shell command.

    If this function is an operation function defined by :class:`~.FlowProject`, it will
    be interpreted to return a shell command, instead of executing the function itself.

    For example:

    .. code-block:: python

        @FlowProject.operation
        @flow.cmd
        def hello(job):
            return "echo {job._id}"
    """
    if getattr(func, '_flow_with_job', False):
        raise RuntimeError(
            '@cmd should appear below the @with_job decorator in your script')
    setattr(func, '_flow_cmd', True)
    return func
