https://github.com/anaethelion/escli-rs
Proof of Concept Command line tool for Elasticsearch
https://github.com/anaethelion/escli-rs
command-line elasticsearch rust
Last synced: 3 months ago
JSON representation
Proof of Concept Command line tool for Elasticsearch
- Host: GitHub
- URL: https://github.com/anaethelion/escli-rs
- Owner: Anaethelion
- License: apache-2.0
- Created: 2025-03-19T16:57:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-27T00:26:03.000Z (4 months ago)
- Last Synced: 2026-03-27T05:23:40.627Z (4 months ago)
- Topics: command-line, elasticsearch, rust
- Language: Rust
- Homepage:
- Size: 2.53 MB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: agents.md
Awesome Lists containing this project
README
# escli-rs
[](https://github.com/Anaethelion/escli-rs/actions/workflows/cli-build.yml)
A modern, flexible command-line interface (CLI) for interacting with Elasticsearch clusters, written in Rust. This project aims to provide a comprehensive and user-friendly tool for managing and querying Elasticsearch, supporting a wide range of Elasticsearch APIs and features.
## Features
- Full CLI for Elasticsearch APIs
- Auto-completion and shell integration
- Secure authentication (API key, username/password, etc.)
- Support for multiple Elasticsearch versions
- Extensible command structure
---
## Quickstart with .env File
You can configure escli using a `.env` file in your project root or working directory. This allows you to securely manage credentials and connection settings without exposing them on the command line.
**Supported variables:**
- `ESCLI_URL` – Elasticsearch endpoint (e.g., https://localhost:9200)
- `ESCLI_API_KEY` – API key for authentication (recommended)
- `ESCLI_USERNAME` – Username for authentication (alternative)
- `ESCLI_PASSWORD` – Password for authentication (alternative)
**Example `.env` using API key (recommended):**
```env
ESCLI_URL=https://localhost:9200
ESCLI_API_KEY=your_api_key_here
```
**Example `.env` using username and password:**
```env
ESCLI_URL=https://localhost:9200
ESCLI_USERNAME=elastic
ESCLI_PASSWORD=yourpassword
```
> **Tip:** If your .env file is not being picked up, ensure you are running escli from the directory containing the .env file, or that your shell environment is loading it.
---
## Getting Started
Use `--help` to see available commands and options, `-h` for the short version.
### Info
```sh
./escli info
```

### Bulk
```sh
./escli bulk --input payload.json
```

### Search
```sh
./escli search --index my_index <<< '{"query": {"match_all": {}}}'
```

### ES|QL
```sh
./escli esql query --format txt <<< '{"query": "FROM | LIMIT 1"}'
```

### Dump
```sh
./escli utils dump
```

### Prerequisites
- Rust (latest stable or nightly)
- Elasticsearch cluster (local or remote)
### Build
```sh
cargo run -p generator --release
cargo build -p escli --release
```
or
```sh
make release
```
### Usage
```sh
./escli --help
```
### Completions
To enable completions, run and then source the output in your shell:
```sh
COMPLETE= ./escli
```
---
## Running escli with Docker
You can build and run the escli container locally. By default, the Dockerfile builds for amd64/musl, which works on most modern PCs.
### Build the Docker image (local, single-arch)
```sh
docker build -t escli:latest .
```
### Recommended: Use a wrapper script for escli via Docker
Save the following as `escli` somewhere on your `PATH` (e.g. `/usr/local/bin/escli`) and make it executable (`chmod +x`):
```sh
#!/bin/sh
[ -t 0 ] && exec docker run --network host -it --rm -e ESCLI_URL -e ESCLI_API_KEY ghcr.io/anaethelion/escli:latest "$@"
exec docker run --network host -i --rm -e ESCLI_URL -e ESCLI_API_KEY ghcr.io/anaethelion/escli:latest "$@"
```
The script adds `-t` when stdin is a terminal (so commands like `search` that optionally read a body don't hang) and falls back to `-i` when stdin is piped (so body input still works).
Then, set your environment variables on the host and use escli as if it were installed locally:
```sh
export ESCLI_URL=https://localhost:9200
export ESCLI_API_KEY=your_api_key_here
escli info
```
This approach makes it easy to use escli in Docker with your local environment and network settings.
### Run escli in a container (manual)
You can also run escli directly with Docker:
```sh
docker run --rm -it escli:latest --help
```
Or mount your .env file if needed:
```sh
docker run --rm -it -v $(pwd)/.env:/.env escli:latest info
```
---
## Workspace Structure
- `escli/` - Main CLI application
- `generator/` - Code generation utilities for CLI and API bindings
## Development
- Contributions are welcome! Please open issues or pull requests.
- See each crate's README or source for more details.
## License
This project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details.