/redis-cli

A compact, interactive tool for Redis, crafted in Go for the "Coding Challenge #37" by John Crickett. Streamlined command execution and easy Redis server interaction.

Primary LanguageGoMIT LicenseMIT

Redis CLI Tool in Go ๐Ÿš€

Overview ๐Ÿ“–

This "redis-cli" project, developed in Go, was created as part of the "Coding Challenge #37 - Redis CLI Tool" by John Crickett. It's designed for effective interaction with Redis servers, encompassing serialization and deserialization of RESP messages, establishing network connections, and offering a user-friendly interface for executing Redis commands.

Features ๐ŸŒŸ

  • RESP Serialization/Deserialization ๐Ÿ’พ: Handles encoding and decoding of RESP messages.
  • Network Connection ๐ŸŒ: Establishes connections to Redis servers.
  • Command Line Interface โŒจ๏ธ: Offers an interactive CLI for executing Redis commands.
  • Flexible Server Connection ๐Ÿ”—: Allows specifying host and port for the Redis server.
  • Extended Command Support ๐Ÿ› ๏ธ: Includes a help command with detailed descriptions of Redis commands.

Getting Started ๐Ÿšฆ

Prerequisites

  • Go (version 1.21 or higher) ๐Ÿน
  • Redis server ๐Ÿ“ฆ

Installation ๐Ÿ› ๏ธ

  1. Clone the repository:

    git clone https://github.com/afonsocraposo/redis-cli
  2. Navigate to the project directory:

    cd redis-cli
  3. Build the project:

    go build -o redis-cli cmd/redis-cli/redis-cli.go

Usage ๐Ÿ“š

Basic Execution

Run the CLI tool:

./redis-cli

Server Connection

Specify the host and port:

./redis-cli -h [hostname] -p [port]

Interactive Mode

Enter commands in the interactive mode:

localhost:6379> set key value
OK
localhost:6379> get key
value

Help Command

Access help for Redis commands:

localhost:6379> help set

SET key value [NX|XX] [GET] [EX seconds|PX milliseconds|EXAT unix-time-seconds|PXAT unix-time-milliseconds|KEEPTTL]
summary: Sets the string value of a key, ignoring its type. The key is created if it doesn't exist.
since: 1.0.0
group: string

Testing ๐Ÿงช

  • The project includes a suite of test cases following the Test-Driven Development (TDD) approach.
  • Run the tests to ensure the functionality of serialization, deserialization, and command execution.

Contributing ๐Ÿค

Contributions to enhance the "redis-cli" tool are welcome. Please follow the standard fork, branch, and pull request workflow.

License ๐Ÿ“„

Distributed under the MIT License. See LICENSE for more information.