phingofficial/phing

CTask proposal

Closed this issue · 1 comments

Is your feature request related to a problem? Please describe.

ExecTask is used to execute commands, but it might be overkill sometimes. For example you are forced to split simple commands into executable and its arguments.

Describe the solution you'd like

I propose to implement CTask, the idea is to be an extremely simple task to execute commands.

In order to be as concise as possible, it must be used as <c> tag (c for command or console) without attributes:

    <target name="demo">
        <c>vendor/bin/phpstan analyse src</c>
    </target>

The previous code is equivalent to:

    <target name="demo">
        <exec executable="vendor/bin/phpstan" passthru="true" checkreturn="true">
            <arg value="analyse"/>
            <arg path="src"/>
        </exec>
    </target>

CTask will never have attributes, if you need anything more advanced then you must switch to ExecTask.

Describe alternatives you've considered

The alternative is to continue using ExecTask.

Additional context

I was motivated to create this proposal because:

  1. People are using composer.json to store simple commands (aka scripts). This is described in: https://blog.martinhujer.cz/have-you-tried-composer-scripts/.
    Npm has a similar feature, you can store commands in package.json.
  2. command attribute (from ExecTask) has been deprecated, therefore you are forced to split your command and use executable attribute, even for simple commands.
  3. A user has requested to restore command attribute (see #1252).
  4. ExecTask has plenty of features, which is good, but sometimes you only want to do simple things.

I can implement CTask if this proposal is accepted.

Finally, this is only a proposal, please feel free to close this issue if you want 🙂

mrook commented

Thanks for the proposal @jawira. For now let's stick with exec as it is and see how that goes.