# espresso-cli

> The command line utility for Espresso Logic

Latest version **1.3.3** (published 2015-01-22) · Apache license · 0 weekly downloads

## Install

```sh
npm install espresso-cli
pnpm add espresso-cli
yarn add espresso-cli
bun add espresso-cli
```

Provides the command `espresso`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2015-01-22 |
| First published | 2014-11-13 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Espresso Logic |
| Maintainers | maxtardiveau |
| Keywords | espresso, logic, command, line, REST, SQL, database, mysql, oracle, nosql, postgres, mongo, sqlserver, mobile, reactive |

## Links

- npm: https://www.npmjs.com/package/espresso-cli
- Repository: https://github.com/EspressoLogicCafe/EspressoLogicCLI
- Issues: https://espressologic.zendesk.com
- npm.io page: https://npm.io/package/espresso-cli

## Dependencies (7)

- [osenv](https://npm.io/package/osenv.md) ^0.1.0
- [colors](https://npm.io/package/colors.md) ^1.0.3
- [cli-table](https://npm.io/package/cli-table.md) 0.3.1
- [commander](https://npm.io/package/commander.md) ^2.5.0
- [easy-table](https://npm.io/package/easy-table.md) 0.3.0
- [underscore](https://npm.io/package/underscore.md) ^1.7.0
- [node-rest-client](https://npm.io/package/node-rest-client.md) ^1.4.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.3.3 (latest) — 2015-01-22
- 1.3.2 — 2014-12-17
- 1.3.0 — 2014-11-21
- 1.2.3 — 2014-11-17
- 1.2.2 — 2014-11-15
- 1.2.1 — 2014-11-15
- 1.1.0 — 2014-11-14
- 1.0.3 — 2014-11-13
- 1.0.2 — 2014-11-13
- 1.0.1 — 2014-11-13
- 1.0.0 — 2014-11-13

## README

# EspressoCLI
A Node.js command-line tool to access Espresso Logic REST API and Logic services. 
Refer to online documentation of creating and using Espresso Logic [REST API](http://docs.espressologic.com/docs/live-api) 


## Installation

1. Make sure [node.js](http://nodejs.org) is installed
2. Install using `npm` by running the following:
```sh
$ npm install -g espresso-cli
```

Note: on Unix and Mac, you will probably need to run this with sudo because of file permissions:

```sh
$ sudo npm install -g espresso-cli
```

*Windows*: Please note that, on Windows, `npm install` will create an executable 
called `espresso` in your
`<node_modules>/.bin` directory. If this directory is not in your `PATH`, you will probably
want to fix that, otherwise you'll have to specify the full path to the executable.


## Features

* Log in once per server, stay "logged in" for the lifetime of the API key
* Can call GET, POST, PUT and DELETE
* Can read/write objects from/to file or stdin (suitable for pipe work!)

## Command Line Service
```sh
$ espresso --help

  Usage: espresso \[options] [command] 

  Commands:

    login [options]               Login to an Espresso Logic server
    logout [options]              Logout from the current server, or a specific server
    use <alias>                   Use the specified server by default
    status                        Show the current server, and any defined server aliases
    get <resource> [options]      Retrieve some data for the given resource/table/view
    post <resource> [options]     Insert some data
    put <resource> [options]      Update some data
    delete <resource> [options]   Delete some data
    describe <resource> [options] Describe the specified resource, can be: tables[/tablename], views[/viewname], license, serverinfo

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

```

## Logon to an Espresso Logic Server
```sh
$ espresso login http://my.espressologic.com/rest/el-dev/demo/v1 -u username -p mypassword
Logging in...
This server licensed to: Espresso Logic
Login successful, API key will expire on: 2014-11-18T15:03:37.342Z
```


## See which Espresso server (if any) you are logged into
```sh
$ espresso status

You are currently logged in to server: https://eval.espressologic.com/rest/acme/demo/v1 as user demo
Defined aliases:
┌───────┬───────────────────────────────────────────────────────────┬───────┐
│ Alias │ Server                                                    │ User  │
├───────┼───────────────────────────────────────────────────────────┼───────┤
│ hr    │ https://acme.my.espressologic.com/rest/acme/hr/v2         │ hradm │
├───────┼───────────────────────────────────────────────────────────┼───────┤
│ demo  │ https://eval.espressologic.com/rest/acme/demo/v1          │ demo  │
└───────┴───────────────────────────────────────────────────────────┴───────┘
```


## DESCRIBE a system resource
This can return information about all tables, or one specific table,
or all views/one specific view, or get information about the server
or the server's license. The possible values for the resource are:

* tables
* tables/&lt;table-name>
* views
* views/&lt;view-name>
* license
* serverinfo

```sh
$ espresso describe tables

DB    Table
----  -------------------
demo  customer
demo  employee
demo  employee_picture
demo  LineItem
demo  product
demo  PurchaseOrder
demo  purchaseorder_audit
```

```sh
$ espresso describe tables/product

Name            Type     Size      PK
--------------  -------  --------  --
product_number  BIGINT         19  *
name            VARCHAR        50
price           DECIMAL        19
icon            BLOB        65535
full_image      BLOB     16777215
```


## GET 
```sh
  Usage: get <resource> [options] 

  Options:

    -h, --help                       output usage information
    -k, --pk <pk>                    Optional: primary key of the object to retrieve
    -f, --filter <filter>            Optional: filter, e.g. "balance<1000"
    -s, --sort <sort>                Optional: sorting order, e.g. "balance,name desc"
    -z, --pagesize <pagesize>        Optional: up to how many rows to return per level
    -m, --format <format>            Optional: format of output, either text (default), json or compactjson    --truncate <length>
    -a, --serverAlias <serverAlias>  Optional: alias of the server to use if other than the current default server
```


## Get a single REST endpoint (compressed format)
```sh
$ espresso get employee

demo:employee/1 employee_id:1 login:sam name:Sam Yosemite
demo:employee/2 employee_id:2 login:mlittlelamb name:Mary Little-Lamb
demo:employee/3 employee_id:3 login:sconnor name:Sarah Connor
demo:employee/4 employee_id:4 login:jkim name:John Kim
demo:employee/5 employee_id:5 login:bmcmanus name:Becky McManus
etc...
```

## GET a single REST endpoint (JSON format)
```sh
$ espresso get employee/4 -m json 
[
  {
    "@metadata": {
      "href": "http://localhost:8080/KahunaService/rest/el-local/demo/v1/demo:employee/4",
      "checksum": "A:3ed29188014675ec",
      "links": [
        {
          "href": "http://localhost:8080/KahunaService/rest/el-local/demo/v1/demo:employee_picture?filter=employee_id%20%3D%204",
          "rel": "children",
          "role": "employee_pictureList",
          "type": "http://localhost:8080/KahunaService/rest/el-local/demo/demo:employee_picture"
        },
        {
          "href": "http://localhost:8080/KahunaService/rest/el-local/demo/v1/demo:PurchaseOrder?filter=salesrep_id%20%3D%204",
          "rel": "children",
          "role": "PurchaseOrderList",
          "type": "http://localhost:8080/KahunaService/rest/el-local/demo/demo:PurchaseOrder"
        }
      ]
    },
    "employee_id": 4,
    "login": "jkim",
    "name": "John Kim"
  }
]
```

## POST (insert) a JSON payload 

```sh
$ espresso post --help

  Usage: post <resource> [options]

  Options:

    -h, --help                       output usage information
    -j, --json <json>                JSON for the data being inserted
    -f, --jsonfile <jsonfile>        Name of a file containing JSON to be inserted, or stdin to read from stdin
    -m, --format <format>            Optional: format of output, either text (default), json or compactjson
    -a, --serverAlias <serverAlias>  Optional: alias of the server to use if other than the current default server

$ espresso post customer -j '{ "name": "new posted record","balance": 0,"credit_limit": 9000 }'

POST for customer:
I demo:customer/new%20posted%20record name:new posted record balance:0 credit_limit:9000
Request took: 61ms - # objects touched: 1
```

## PUT (update) a JSON Payload

```sh
$ espresso put --help

  Usage: put <resource> [options]

  Options:

    -h, --help                       output usage information
    -j, --json <json>                JSON string for the data being updated
    -f, --jsonfile <jsonfile>        Name of a file containing JSON to be updated, or stdin to read from stdin
    -m, --format <format>            Optional: format of output, either text (default), json or compactjson
    -a, --serverAlias <serverAlias>  Optional: alias of the server to use if other than the current default server
    
$ espresso put customer -j '{ "@metadata": {"checksum": "A:693190f461f5402e"  }, "name": "new posted record", "credit_limit": 8000  }'

PUT for customer:
U demo:customer/new%20posted%20record name:new posted record balance:0 credit_limit:8000
Request took: 42ms - # objects touched: 1
```

## DELETE a REST resource

```sh
$ espresso delete --help

  Usage: delete <resource> [options]

  Options:

    -h, --help                       output usage information
    -k, --pk <pk>                    Primary key of the object to delete
    --checksum <checksum>            Optional: checksum for the object to delete, or "override". If not specified, the object will be retrieved then deleted.
    -f, --jsonfile <jsonfile>        Optional: name of a file containing JSON to be deleted, or stdin to read from stdin
    -m, --format <format>            Optional: format of output, either text (default), json or compactjson
    -a, --serverAlias <serverAlias>  Optional: alias of the server to use if other than the current default server

espresso delete customer -k "new posted record" --checksum "A:e86aea2e0a4e74bf" 
```
## Logout

```sh
$ espresso logout
Logout successful
```

---
_Source: https://npm.io/package/espresso-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
