<div align="center">
  <a href="https://www.emojione.com/emoji/2697">
    <img height="120" width="120" alt="alembic" src="https://raw.githubusercontent.com/reservix/laborious/master/assets/alembic.png" />
  </a>
</div>

# laborious

[![buid][ci-badge]][ci] [![version][version-badge]][package] [![MIT License][license-badge]][license]

> CLI tools for the lazy Gitlab developer.

`laborious` is a CLI app to execute common tasks (create Merge Request, checkout Merge Request for review, ...) without the need to access Gitlab's web view.

## Install

_Requires git 2.7+ and node 8+ to be installed._

```
$ yarn add -D laborious
```

or

```
$ npm install -D laborious
```

## Usage

It is recommended to add `laborious` to your `package.json`'s scripts. This way you have easy access to all commands via `yarn`/`npm`.

For example, if you add the following to your scripts, you can do `yarn lab <command>` or `npm run lab <command>` to run `laborious`.

```json
{
  "scripts": {
    "lab": "laborious"
  }
}
```

### Available Commands

Note, you can run `laborious` without any commands to view the help and get an overview of all available commands.

#### `init`

_Alias: i_

Create a `laborious.json` configuration file. You'll get ask some questions and the file will be created for you afterwards.

#### `open`

_Alias: o_

Uses your default browser to open the homepage of your project in Gitlab.

#### `merge-request`

_Alias: mr_

Create a merge request for the current branch. The target branch is specified in your `laborious` config.

#### `checkout`

_Alias: co_

List available Merge Requests and branches. Select one of them to switch to the corresponding branch. This will also try to update the branch to the latest commit.

#### `ping`

Ping Gitlab API.

## Configuration

In order to get information about your project from Gitlab, `laborious` uses the configured git origin to infer the location of the Gitlab API. Make sure your project is hosted on (self-hosted) Gitlab! If you want to test, if `laborious` can reach your Gitlab, use the `ping` command.

### Authentication

Some commands, like creating a Merge Request, require authentication. `laborious` will ask you for a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) if this is the case.

You can also add the token manually, by creating a `.laborious` in your home directy.

## Integration with `yargs`

Since `laborious` is using [`yargs`](https://github.com/yargs/yargs) as CLI framework, you can require commands directly if you're already have your own CLI build with `yargs`.
To integrate `laborious`' commands in your CLI you can do the following:

```js
import { getCommandsDir } from 'laborious';
import yargs from 'yargs';

const argv = yargs
  .commandDir('./my-commands')
  .commandDir(getCommandsDir())
  .alias('help', 'h').argv;
```

<!-- LINKS -->

[ci]: https://travis-ci.org/Reservix/laborious
[ci-badge]: https://img.shields.io/travis/Reservix/laborious.svg?style=flat-square
[license]: https://github.com/Reservix/laborious/blob/master/LICENCE
[license-badge]: https://img.shields.io/npm/l/laborious.svg?style=flat-square
[package]: https://www.npmjs.com/package/laborious
[version-badge]: https://img.shields.io/npm/v/laborious.svg?style=flat-square
