All about Exporters

Exporters are part of the Crossbelt plugin system and allow you to export data into any format or service.

Why

Everyone uses Crossbelt differently so the need for custom exporters can strengthen the usefulness of the Crossbelt system. By default Crossbelt displays data in table format. While this is good for console users, some users may wish to see the data in a different format like csv format.

With csv format users can now import the data directly into a spreadsheet application.

While power users may send data in JSON format to a custom http endpoint.

We don’t want to restrict anyone’s needs so we made the export system pluggable, which makes the possibilities endless.

How to use

The export system takes one or more exporters in the order you specify supplied via the --exporters option. Each exporter will output the transformed data to the input of the next exporter. You can think of this feature similar to linux unix pipes where the output of one command is sent to the input of another command. While you could use unix pipes to export data we thought it would be nice if some abilities were baked into crossbelt for easier accessibility.

This gives you the ability to come up with lots of different combinations for exporting data.

There are two different types of exporters to know:

  1. exporters that transforms data.
  2. exporters that transmits data.

Keep this in mind when mixing exporters together since the results can be different.

In the default setting --exporters='table,stdout' we tell crossbelt to transform the raw data into an ascii table. Then take that transformed data and transmit it to stdout (the console). This is the default for most cli commands.

But lets say you want JSON format. --exporters='json'. This will transform the data into JSON format. By default you won’t see any returned output, so you also need to add a transmit exporter. --exporters='json,stdout'. By adding the stdout exporter the JSON data will be sent to the console.

However, lets say you want the data sent to the showme service. --exporters='json,showme'.

Or you want to send the ascii table instead --exporters='table,showme' or maybe yaml --exporters='yaml,showme'

The possibilities are endless and as time goes on there will be more exporters to choose from.

Listing exporters

You can get a list of installed exporters at any time by running cb plugins ls

$ cb plugins ls 
NAME    | TYPE     | VERSION | DESC
--------|----------|---------|-------------------------------
console | exporter | 0.0.1   | Outputs content to the cons...
yaml    | exporter | 0.0.1   | Outputs object into YAML fo...
table   | exporter | 0.0.1   | Returns contents into table...
ruby    | exporter | 0.0.1   | Returns ruby object
json    | exporter | 0.0.1   | Outputs object into JSON fo...
csv     | exporter | 0.0.1   | Returns contents into csv f...
ini     | exporter | 0.0.1   | Outputs object into INI (ke...
showme  | exporter | 0.0.1   | Outputs content to the show...
stdout  | exporter | 0.0.1   | Outputs content to stdout
gsheets | exporter | 0.0.1   | Dumps the output to a googl...

You will use this table often as a reference.

Installing custom exporters

You can add new exporters at any time by using the cb plugins install command.

$ cb plugins install --pname=crossbelt-ipfs
Crossbelt Plugin crossbelt-ipfs installed successfully

Currently there is only a crossbelt-ipfs plugin to install but more will be added over time.

Creating new exporters

We are still creating the plugin API specification, so the details for crafting your own plugin have not been released. Once our 1.0 release hits the stores expect to see documentation for creating your own exporter.