##### <[...Prev](../README.md "Back to Contents")> <[Contents](../README.md)> <[Next...](standard-functions.md "Next to Standard functions")>

---

## Get started

### 1.1

#### Install

```shell
git clone https://github.com/webliumteam/api-cli.git
cd api-cli
npm link
```

now you can use `wm-cli` shell command with next global options:

| Option   | Alias | Description  | Type    |
|----------|-------|--------------|---------|
|--version |       | Show version | boolean |
|--help    |       | Show help    | boolean |
|--username| -u    | Username for single command | string |
|--password| -p    | Password for single command | string |
|--host    | -h    | Server host for single command (example: `http://weblium.com)`| string |
|--console |       | type of output data (default: "dir")| enum (dir, json, log, raw) |

To enable autocompletion append `source <(wm-cli completion | sed s/\$\(.*wm-cli/\$\(wm-cli/)` to `~/.bashrc` file and restart shell

```shell
echo '
source <(wm-cli completion | sed s/\$\(.*wm-cli/\$\(wm-cli/)
' >> ~/.bashrc
```

### 1.2

#### Create new user

Append new user if you don't have it.

```shell
wm-cli -u admin@weblium.com -p JxXLagTAB6 -h http://localhost:3000 user add '{
  "username": "myname@weblium.com",
  "password": "developerpassword",
  "name": "Myname",
  "role": "customer",
  "customer": {"developer": true}
}'
```

### 1.3

#### Login

it will create ~/.wm-auth.json file with authorization info to store current login context

```shell
wm-cli login -u myname@weblium.com -p mypassword -h http://localhost:3000
```

### 1.4

#### Who am I

Check current user after login

```shell
wm-cli whoami
```

Success result:

```json
{
  "data": {
    "_id": "59020c4f1e91b6001f220580",
    "role": "admin",
    "idPrefix": "UA",
    "idBody": 1,
    "idPostfix": "W",
    "username": "admin@weblium.com",
    "employee": {
      "administrator": false,
      "artdirector": false,
      "marketing": false,
      "support": false,
      "stockmanager": false
    },
    "iat": "2017-11-06T08:46:41.000Z",
    "exp": "2017-11-07T08:46:41.000Z"
  },
  "now": 1509958001257,
  "messageId": 6,
  "status": 200,
  "request": {
    "action": "auth.whoami",
    "messageId": 6
  },
  "host": "http://localhost:3000"
}
```

---

##### <[...Prev](../README.md "Back to Contents")> <[Contents](../README.md)> <[Next...](standard-functions.md "Next to Standard functions")>
