> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nihalxkumar.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Client

> Command-line interface for Zingat - Create and manage clips from the terminal

Zingat includes a command-line client (`clipclient`) for creating and managing clips from the terminal.

## Installation

The CLI client is built as part of the Zingat project:

```bash theme={null}
# Build the CLI client
cargo build --release --bin clipclient

# Install globally (optional)
cargo install --path . --bin clipclient
```

```
Zingat API Client

USAGE:
    clipclient --api-key <api-key> [addr] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --api-key <api-key>    

ARGS:
    <addr>     [env: ZINGAT_ADDR=]  [default: http://127.0.0.1:8000]

SUBCOMMANDS:
    get       
    help      Prints this message or the help of the given subcommand(s)
    new       
    update    
```

## Basic Usage

```bash theme={null}
clipclient --api-key <api-key> [addr] <SUBCOMMAND>
```

**Options:**

* `--api-key <api-key>`: API key for authentication (required)
* `[addr]`: Server address (optional, defaults to `http://127.0.0.1:8000`)
  * Can also be set via `ZINGAT_ADDR` environment variable

**Subcommands:**

* `get`: Retrieve a clip by shortcode
* `new`: Create a new clip
* `update`: Update an existing clip
* `help`: Show help information

## Examples

### Generate API Key

First, generate an API key:

```bash theme={null}
# Get API key from server
xh GET http://localhost:8000/api/clip/key
```

### Create Clip

```bash theme={null}
# Create a new clip with default address
cargo run --bin clipclient -- --api-key <key> new "Hello from CLI"

# Create a clip with title, password, and expiry
cargo run --bin clipclient -- --api-key <key> new "Content here" \
  --title "My Clip" \
  --password "secret123" \
  --expires "2024-12-31"

# Create a paste on a remote server
cargo run --bin clipclient -- --api-key <key> https://zingat.example.com new "Remote paste"
```

### Get Clip

```bash theme={null}
# Get a clip by shortcode
cargo run --bin clipclient -- --api-key <key> get <shortcode>

# Get clip from remote server
cargo run --bin clipclient -- --api-key <key> https://zingat.example.com get <shortcode>
```

### Update Clip

```bash theme={null}
# Update an existing clip
cargo run --bin clipclient -- --api-key <key> update <shortcode> "Updated content"

# Update with all options
cargo run --bin clipclient -- --api-key <key> update <shortcode> "New content" \
  --title "Updated Title" \
  --password "newpass" \
  --expires "2025-01-01"
```

### Using Environment Variable

```bash theme={null}
# Set server address via environment variable
export ZINGAT_ADDR=https://zingat.example.com
cargo run --bin clipclient -- --api-key <key> new "Content"
```
