Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rickbarretto/tasks

A rake-inspired task system for Arturo
https://github.com/rickbarretto/tasks

Last synced: 5 days ago
JSON representation

A rake-inspired task system for Arturo

Awesome Lists containing this project

README

        


Tasks


Tasks is a lean tasking system based on

Ruby's Rake




Arturo logo
Arturo logo

## At a Glance


Running Tasks from terminal
Running Tasks from terminal

## Trying Tasks

*Tasks* may be splited into two sections: *runner* and *definitions*.

*The runner* is the section responsible to get the user input and then execute the defined tasks.
While *the definitions* are responsible to group the rules and logic of each task.

At your task file, you can do:

```art
import {tasks}!

; here goes the task definition

runTask "my-task"
```

And then, runnning with:

```
arturo tasks.art
```

> [!TIP]
> You may want to use a hashbang to don't need to call arturo for every run.
> Try: `#! arturo`

> [!TIP]
> To dynamically select the task via CLI, use:
> ```art
> import {tasks}!
>
> ; tasks goes here
>
> ensure.that: "Argument needed for this script"
> -> not? empty? arg
> runTask arg\0
> ```

### The *tasks' definition* itself

A real example of tasks:

```art
import {tasks}!

routine 'test [
|> 'echo {Testing source code...}
]

task 'build .requires: [test] [
source: ["./tests/example/example.c"]
directory ./"tests/bin"

file.as: 'f ./"tests/bin/example.exe" .requires: source [
|> 'gcc print <= ~{|join.with: " " f\requires| -o |f\file|}
]
]

task 'run [
file ./"tests/bin/example.exe" .as: 'f
-> execute.directly f\file
]

task 'clean [
delete.directory ./"tests/bin"
]

runTask 'build
runTask 'run
runTask 'clean
```

This will show you:

```

==================================================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ミ BUILD ミ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==================================================================================

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~〃 test 〃~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Testing source code...

./tests/example/example.c -o tests\bin\example.exe

==================================================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ミ RUN ミ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==================================================================================

Hello, from Arturo's tasks

==================================================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ミ CLEAN ミ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==================================================================================

```

## Documentation

### *Runner*
- `runTask: $[target :string :literal]`:
Runs the `target` task

### *Task Definition*
- `directory: $[path :string]`:
Creates a directory. The same as `write.directory path null`.
- `file: $[filename :string action :block]`:
Defines a file. Files may require other files to exist. And also can be threated by other name using `.as`.
- `.as :literal`:
Wraps the file and its requirements into a dictionary: `#[file :string requires [:string]]`
- `.requires`:
The required files to this file exist. If none is passed, the files depends on itself.
- `exec $[command :string :literal params :string]`:
Executes a command on shell.
- alias: `|>`.
- OBS.: This function is only available into `action`s from `routine`s and `task`s.
- `routine: $[name :string :literal, action :block]`:
Defines a `:routine` that executes an `action`.
- `task: $[name :string :literal, action :block]`:
Defines a `:task`, every task is a `:routine` but executable direclty from the `executeTask`.
- `.requires [:literal :string :word]`:
Defines the required routines to run this.
- `.defers [:literal :string :word]`:
Defines the required defer routines.

> [!WARNING]
> Never import this lib as `.lean`, or this will break the current code.
> This happens due to the nature of Arturo (being kind-of concatenative).

## Roadmap

- [ ] Help command
- [ ] Accept `--help` flag
- [ ] Add description for each task
- [ ] Accept the `--help`flag for each task
- [ ] Better error reporting
- [ ] Avoid to use `ensure`, and throw a proper error
- [ ] Bundle an executable, so you won't need the runner anymore
- [ ] Pass arguments for the task

---

> Screenshot's wallpaper photo by Nick Scheerbart on Unsplash