couchbaselabs / couchbase-shell

Shell yeah!
http://couchbase.sh
Apache License 2.0
65 stars 13 forks source link
couchbase rust shell

Couchbase Shell - Shell Yeah!

CI

Couchbase Shell (cbsh) is a modern, productive and fun shell for Couchbase Server and Cloud.

Note that while the project is maintained by Couchbase, it is not covered under the EE support contract. We are providing community support through this bug tracker.

The documentation is available here.

Quickstart

First, download the archive for your operating system.

You do not need any extra dependencies to run cbsh, it comes "batteries included".

macOS Users: You will need to grant the binary permissions through Security & Privacy settings the first time you run it.

After extracting the archive, run the cbsh binary in your terminal.

❯ ./cbsh --version
The Couchbase Shell 0.75.1

Basic Usage

Once the binary is available, you can connect to a cluster on the fly and run a simple command to list the (user-visible) buckets.

❯ ./cbsh --connstr 127.0.0.1 -u username -p
Password:
πŸ‘€ username 🏠 default in πŸ—„ <not set>
> buckets
───┬─────────┬───────────────┬───────────┬──────────┬──────────────────────┬───────────┬───────────────┬────────┬───────
 # β”‚ cluster β”‚     name      β”‚   type    β”‚ replicas β”‚ min_durability_level β”‚ ram_quota β”‚ flush_enabled β”‚ status β”‚ cloud
───┼─────────┼───────────────┼───────────┼──────────┼──────────────────────┼───────────┼───────────────┼────────┼───────
 0 β”‚ default β”‚ beer-sample   β”‚ couchbase β”‚        1 β”‚ none                 β”‚  209.7 MB β”‚ false         β”‚        β”‚ false
 1 β”‚ default β”‚ default       β”‚ couchbase β”‚        1 β”‚ none                 β”‚  104.9 MB β”‚ true          β”‚        β”‚ false
 2 β”‚ default β”‚ targetBucket  β”‚ couchbase β”‚        0 β”‚ none                 β”‚  104.9 MB β”‚ true          β”‚        β”‚ false
 3 β”‚ default β”‚ travel-sample β”‚ couchbase β”‚        1 β”‚ none                 β”‚  209.7 MB β”‚ false         β”‚        β”‚ false
───┴─────────┴───────────────┴───────────┴──────────┴──────────────────────┴───────────┴───────────────┴────────┴───────

While passing in command-line arguments is fine if you want to connect quickly, using the dotfile ~/.cbsh/config for configuration is much more convenient. Here is a simple config which connects to a cluster running on localhost:

version = 1

[[cluster]]
identifier = "my-local-cb-node"
hostnames = ["127.0.0.1"]
default-bucket = "travel-sample"
username = "Administrator"
password = "password"

After the config is in place, you can run ./cbsh without any arguments and it will connect to that cluster after start automatically.

The downloaded archive contains an example directory which also contains sample configuration files for more information. Also, please see the docs for full guidance, including information about how to work with multiple clusters at the same time.

cbsh commands

On top of nushell built-in commands, the following couchbase commands are available:

Building From Source

If you want to build from source, make sure you have a modern rust version and cargo installed (ideally through the rustup toolchain).

After that, you can build and/or run through cargo build / cargo run. By default it will build in debug mode, so if you want to build a binary and test the performance, make sure to include --release.

Installing as a binary through cargo

If you just want to use it and don't want to bother compiling all the time, you can use cargo install --path . to install it into your cargo bin path (run from the checked out source directory).

❯ cargo install --path .
  Installing couchbase-shell v0.75.1 (/Users/michaelnitschinger/couchbase/code/rust/couchbase-shell)
    Updating crates.io index
  Downloaded plist v1.2.1
  Downloaded onig v6.3.0
  Downloaded string_cache v0.8.2
  Downloaded num-bigint v0.4.2
  ...

Grab a quick coffee or tea since this will take some time to compile.

License

Couchbase Shell is licensed under the Apache 2.0 License.

Couchbase Shell is made possible through open source components as listed with their licenses in NOTICES.

Usage of Couchbase Shell is subject to the Couchbase Inc. License Agreement