:rl: pass:q[`ruled-labels`]

== Getting started

Upon doing the <<install>>, a new command called {rl} will be available on your system

The minimum you will need is a <<specs>> file. It is usually called `specs.yml` and {rl} will find it by default if you are using this name.

Having your <<specs>>, you can call {rl} to check a set of labels. Here is how it looks like:

    ruled-labels check --labels A1,B1

Alternatively, you can also call:

    ruled-labels check -l A1 -l B1

The following calls are NOT valid:

- `ruled-labels check --labels A1, B1`
- `ruled-labels check --labels A1 B1`

Check out the <<usage>> to learn more about the available commands. and options.

In most case, you will not call the check command manually, but let your CI take care of that.

First, you may fetch the labels of your PR:

    API_BASE=https://api.github.com/repos
    REPO=...
    GITHUB_PR=1234
    labels=$( curl -H "Authorization: token $GITHUB_TOKEN" -s "$API_BASE/$REPO/pulls/$GITHUB_PR" | jq '.labels | .[] | .name' | tr "\n" ",")

You can now remove the leading `,` that is not useful:

    labels_args=${labels: :-1}

WARNING: Before using the `labels_args`, you want to ensure you are using `IFS=","` so your shell does not split one label containing a space into 2 strings made of a valid label and one that will fail.

And finally run the check:

    ruled-labels check --dev --labels $labels_args

If you prefer using a docker image, here is how it looks like:

    docker run --rm -i -e labels_args -v $PWD/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --dev --labels $labels_args
