maid icon indicating copy to clipboard operation
maid copied to clipboard

Introduce support for running multiple tasks in series

Open tunnckoCore opened this issue 6 years ago • 8 comments

Because why not? It's easy addition.

Example (seen even in the maid's npm scripts)

maid lint test build

# equivalent of
maid lint && maid test && maid build

tunnckoCore avatar Jun 06 '18 09:06 tunnckoCore

I guess this is unnecessary and it will be impossible to pass arguments to the task. https://github.com/egoist/maid#read-command-line-arguments

egoist avatar Jun 06 '18 09:06 egoist

Yes. But this also may be a problem i'm describing here https://github.com/egoist/maid/pull/37#issuecomment-394989509

What if CLI that you run from task have also such task?

Let's consider an example that CLi that you want to run have command and optional sub-command such signature like yarn help add. Currently if want to run only yarn help from a task named add in your maidfile (e.g. maid add), it will actually run yarn help add :D Of course, this example is very specific, but just to get the point.

## add

Some description

```sh
yarn help
```

tunnckoCore avatar Jun 06 '18 09:06 tunnckoCore

I just thought... We can allow running multiple commands behind maid run task1 [task2] [task3] command or through --run flag e.g. maid --run task1 task2 task3 - which btw can't be workarounded here even with = after the --run, until we are kind of forced to use maid --run=task1,task2,task3 (because how cac works).

But yea, you are kind of right, because we can use such maidfile to accomplish "run in series".

## full

```sh
maid lint && maid test && maid build 
```

## lint

```sh
eslint src
```

## test

```sh
ava tests/
```

## build

```sh
babel src -d dist
```

so then just maid full

tunnckoCore avatar Jun 06 '18 09:06 tunnckoCore

Building a task runner is a bit tricky some times. I know what it is, because I'm facing such problems, decisions and ideas while building v3 of hela. Should pay some trade-offs. But i'm based on sade so don't have much problems, even can have sub-commands/sub-tasks without any problems - can have such descriptive definition of tasks

I've workedaround those conflicting by filtering out hela's flags, so they are not passed to the executed command.

So to recap. We can close, your decision :)

tunnckoCore avatar Jun 06 '18 09:06 tunnckoCore

You might get even fancier with maidfile.md

## full
Run tasks `one` `two` `three` after this

## one
```js
console.log(1)
```

## two
```js
console.log(2)
```

## three
```js
console.log(3)
```

Though something like

## full
Run tasks <tasks>

(no this, no before \ after) that resuls in

starting full
starting one
finished one

starting two
finished two

starting three
finished three

finished full

Might be really handy sytax sugar that would still allow for arguments and easy to type command

v-trof avatar Jun 06 '18 19:06 v-trof

@VsevolodTrofimov mmm yeah. More and more considering that this PR can be closed. The point of markdown-driven task runner is to use markdown insead of cli for most of things (such like running multiple commands/tasks)

tunnckoCore avatar Jun 06 '18 20:06 tunnckoCore

@tunnckoCore I have access to start merging, would you fix the conflicts and I will merge today. Thanks.

jakepearson avatar Oct 09 '18 11:10 jakepearson

What conflicts? There are no conflicts.

The thing is that i'm still not sure if we want this.

tunnckoCore avatar Oct 09 '18 13:10 tunnckoCore