# CLI

> The Communications Mining™ Command Line Interface, `re`, is a unified tool that provides a consistent interface for interacting with all parts of Communications Mining from a terminal.

The Communications Mining™ Command Line Interface, `re`, is a unified tool that provides a consistent interface for interacting with all parts of Communications Mining from a terminal.

`re` simplifies managing Communications Mining resources, such as sources and datasets, as well as importing or exporting communications data. Additionally, `re` maintains multiple contexts, making it easy to switch between multiple authentication tokens for different users, service accounts or Communications Mining endpoints.

The Communications Mining CLI is open source and developed on [GitHub](https://github.com/reinfer/cli).

## Features

* **Create**, **get**, **update** and **delete** operations for all the different Communications Mining resources. This includes sources, datasets, comments, buckets, streams and more.
* Context management for multiple API tokens and Communications Mining endpoints.
* Easily upload new messages to a source.
* Download messages from a set of sources and datasets together with the human applied annotations. Useful for backups, migrating data or for applying some transformations to the data.
* Basic shell autocompletion for `zsh` and `bash`, colorized terminal output, progress bars and more

## Installation

**Binary**

Statically linked binaries with no dependencies are provided for all major platforms

* [Linux (x86_64-unknown-linux-musl)](https://github.com/reinfer/cli#binary)
* [macOS (x86_64-apple-darwin)](https://github.com/reinfer/cli#binary)
* [Windows (x86_64-pc-windows-gnu)](https://github.com/reinfer/cli#binary)

**From Source**

To build from source, you need a recent version of the [Rust toolchain](https://rustup.rs/) installed. To install using cargo.

```
cargo install --locked reinfer-cli
```

Ensure you have the cargo bin directory in your path (typically `~/.cargo/bin`).

Alternatively, you can always clone the repository and build it with `cargo build`.

## Help

The Communications Mining™ CLI ships with a lot of command documentation that is accessible with the `--help` or `-h` flag.

```
$ re --help
$ re <command> --help
$ re <command> <subcommand> --help
```

We encourgage you to use read the included documentation as it's extensive and always up to date.

```
$ re --help

reinfer-cli 0.11.0
re is the command line interface to reinfer clusters

USAGE:
    re [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Enable more verbose logging

OPTIONS:
    -k, --accept-invalid-certificates <accept-invalid-certificates>
        --config-file <config>
            Path to the configuration file. Typically defaults to ~/.config/reinfer on Linux

    -c, --context <context>
            Specify what context to use. Overrides the current context, if any

        --endpoint <endpoint>
            Specify what endpoint to use. Overrides the one from the current context, if any

    -o, --output <output>
            Output format. One of: json, table [default: table]

        --proxy <proxy>
            URL for an HTTP proxy that will be used for all requests if specified

        --token <token>
            Specify what API token to use. Overrides the one from the current context, if any

SUBCOMMANDS:
    completion    Output shell completion code for the specified shell (bash or zsh)
    config        Manage reinfer authentication and endpoint contexts
    create        Create new resources
    delete        Delete a resource
    get           Display resources and export comments to the local filesystem
    help          Prints this message or the help of the given subcommand(s)
    update        Update existing resources
```

## Troubleshooting

To troubleshoot issues with the Communications Mining CLI, the following may be useful

* Make sure the latest version of `re` is installed. Get the installed version by running `re --version` or `re -V`
* The `--verbose` flag prints debugging messages, which may narrow down the issue.
* Connection issues may be due to improperly configured proxy settings. For more details, check Using a Proxy to configure request proxying.
* The Communications Mining CLI configuration directory is system specific, e.g. `~/.config/reinfer` on Linux or macOS and `%AppData%/reinfer` on Windows. It can safely be deleted and the CLI will repopulate it, but all configuration (including user sessions) will be lost.

If there is anything you feel we can do to improve it or if you encounter any bugs or unexpected behavior, please [contact support](https://customerportal.uipath.com/support/add-case).
