tutorial

Tutorial: Using the STRM Privacy CLI

5 min read

Our command line interface is the easiest way to create, configure and manage your privacy streams. This tutorial will quickly show you how to install and use our CLI.

by STRM.team on

Note: We’ve updated our CLI in the meantime. Install steps are still the same, but make sure to check this post for updates to the command structure.

Scope

In this quick tutorial, we will touch upon

  • Installing the CLI and checking if everything works as advertised
  • The command structure
  • Creating and deleting a stream as an example

First things first: sign-up

To use the CLI, you need an account. Create an account now if you haven’t signed up yet. If you just want to play around, we only need your e-mail. Confirm the e-mail so we’re sure it’s you.

1. Install our CLI

To get your hands on the CLI, simply tap Homebrew:

brew install strmprivacy/cli/strm

If you can’t or don’t want to use Homebrew, check the STRM Privacy CLI repository on Github to install on other systems and grab the latest release.

Note older versions of our CLI were only distributed as a binary install. If you have it running on your system (check it with strm --help), make sure to remove that distribution, for example with rm "/usr/local/bin/strm"). If you already installed through Homebrew, don’t forget to link it with brew link strm.

2. Enable tab completion

Tab completion makes it easy to navigate through the command structure. During install, Homebrew should give you a heads-up that you need to enable tab completion. If you missed it, brew info strm pulls it up:

==> Caveats
In order to set up auto completion, please follow the instructions below. When you\'ve set up auto completion in the past, you can skip these instructions.

for bash users
add the following line to your .bash_profile or .bashrc:
source <(strm completion bash)

to load completions for each session, execute once:
- Linux users: strm completion bash > /etc/bash_completion.d/strm
- macOS users: strm completion bash > /usr/local/etc/bash_completion.d/strm

for zsh users
ensure that shell completion is enabled, then run (only needs to be done once):
/bin/zsh -c \'strm completion zsh > "${fpath[1]}/_strm"\'

for fish users
source "strm/path.fish.inc"

Follow the instructions depending on your shell of choice and restart your terminal.

3. The CLI’s command structure

Everyone has a great example in life, and ours is kubectl.

We’re kidding, but do believe a verb-oriented command structure offers clean, simple and descriptive navigation and we’ve included sensible defaults if you don’t explicitly set your flags.

Creating a stream is straightfoward: strm create stream.

The same goes for deletion or other management commands: strm delete stream [name] deletes a stream and with strm egress [name] you can simply read from a privacy stream.

The full command structure is available behind the --help flag:

❯ strm --help                                                                 ~
STRM Privacy CLI 1.0.0

Usage:
strm [command]

Available Commands:
auth Authentication command
completion Generate completion script
create Create an entity
delete Delete an entity
egress Read from egress
get Get an entity
help Help about any command
list List entities
sim Simulate events
version Print CLI version

4. Using tab completion

The reality is you’re spending your time in more than a few other CLI’s, too. To lift that burden, tab completion helps you to easily navigate from the main level to deeper levels strm [command] [level down].

Just hit tab wherever you are in the CLI to see which commands are available:

❯ strm [tab]                                                                                     ~
auth -- Authentication command
completion -- Generate completion script
create -- Create an entity
delete -- Delete an entity
egress -- Read from egress
get -- Get an entity
help -- Help about any command
list -- List entities
sim -- Simulate events
version -- Print CLI version

Or see how you can `list’ your streams:

❯ strm list [tab]                                                         ~
batch-exporters -- List batch-exporters
event-contracts -- List event-contracts
kafka-clusters -- List kafka-clusters
kafka-exporters -- List kafka-exporters
kafka-users -- List kafka-users
key-streams -- List key streams
schemas -- List schemas
sinks -- List sinks
streams -- List streams

5. Example: authenticate and create your first stream.

To authenticate to our platform, run the auth login command:

#authenticate
❯ strm auth login [your@email.com]
❯ Enter password: ***

This will set up the necessary tokens to safely communicate with our API’s.

Creating a stream is done through the create stream command:

#create stream
❯ strm create stream winston

Note: Once you create a stream, you get a set of credentials. It’s important to securely store this in a file somewhere to use inside your apps. You cannot access your data in any other way .

And that’s it

If you want to dive deeper, see how you can simulate sending to and reading from a privacy stream directly from the CLI or head over the our documentation.

Thanks!

PS Curious what goes on behind those CLI commands? We’re hiring!

Do you want to build faster and cheaper without worrying about privacy?