Skip to content

nil-omen/greenlight-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Greenlight CLI Client

A beautiful, interactive terminal-based client for the Greenlight API, built with BubbleTea and Lip Gloss.

Manage movies, users, and tokens from your terminal with a rich, navigable TUI.


Features

  • πŸ”— Connect to any Greenlight API β€” Set the base URL on launch with automatic health verification.
  • πŸ” Full Authentication Flow β€” Login, register, activate account, forgot/reset password.
  • 🎬 Movie Management β€” List, search, create, edit, and delete movies with confirmation prompts.
  • πŸ”Ž Advanced Search & Filtering β€” Filter movies by title, genres, year, runtime, or ID using inline overlays.
  • πŸ“„ Pagination β€” Navigate multi-page result sets with arrow keys.
  • πŸ“‹ Raw JSON Viewer β€” Inspect full API responses for any movie, ready to copy.
  • πŸ₯ Health Check β€” View API status, environment, and version at a glance.
  • βš™οΈ Account Settings β€” View your profile, reset your password, or log out.
  • πŸ›‘οΈ Safety Prompts β€” Confirmation dialogs before destructive actions (delete, edit save).

Prerequisites

  • Go 1.25+
  • A running instance of the Greenlight API
  • Just command runner (optional but recommended)

Installation

There are two ways to install the Greenlight CLI:

Option 1: Download Pre-built Binary (Recommended)

You can download the latest pre-compiled executables for Linux, Windows, and macOS directly from the GitHub Releases page. Simply extract the binary matching your operating system and run it directly in your terminal.

Option 2: Compile from Source

If you prefer to build the project yourself, ensure you have Go 1.25+ installed:

# Clone the repository
git clone https://github.com/nil-omen/greenlight-client.git
cd greenlight-client

# Install dependencies
go mod tidy

# Build the binary
just build
# or without just:
go build -o ./bin/client ./cmd/cli

Quick Start

# If running a downloaded release:
./greenlight-client-linux-amd64

# If running from source (Dev mode):
just run

# Or run the compiled source binary:
./bin/client

On launch, you'll be prompted to enter your Greenlight API URL (e.g., http://localhost:4000). The client will verify the connection via the health check endpoint before proceeding.


Usage Guide

Navigation

The app uses a consistent set of keybindings across all views:

Key Action
↑ / ↓ Navigate menu items / table rows
enter Select / submit
esc Go back to previous screen
tab / shift+tab Next / previous form field
ctrl+c Quit the application

1. Connecting to the API

When the app launches, enter the base URL of your Greenlight API:

β”Œβ”€ Set API URL ──────────────────────────┐
β”‚                                        β”‚
β”‚  Enter Greenlight API URL:             β”‚
β”‚  > http://localhost:4000               β”‚
β”‚                                        β”‚
β”‚  enter: connect β€’ ctrl+c: quit         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The client automatically calls GET /v1/healthcheck to verify the connection.


2. Authentication

After connecting, you'll see the onboarding menu:

> 1. Login
  2. Create New User
  3. Activate User
  4. Forgot Password

Login

Enter your email and password. On success, the authentication token is stored in memory and used for all subsequent API calls.

Create New User

Register with a name, email, and password. After successful registration, you'll be redirected to the activation page.

Activate User

Enter the activation token sent to your email to activate your account.

Forgot Password

Enter your email to receive a password reset token, then use it on the reset page with your new password (entered twice for confirmation).


3. Dashboard

Once authenticated, the dashboard provides access to all features:

  Greenlight Dashboard

> 1. List / Search Movies
  2. Add New Movie
  3. Health Check
  4. Account Settings
  5. Exit

  ↑/↓: navigate β€’ enter: select β€’ ctrl+c: quit

4. Movie List & Search

The movie list defaults to showing the 10 most recently added movies (sort=-id, page_size=10).

Search Keybindings

Press any of these keys while in the list view to open a search overlay:

Key Filter Example Input
t Title moana
g Genres action, adventure
y Year 2016
r Runtime 107 or 107 mins
i ID 1

Note: Genres accept both action,adventure and action, adventure (spaces are stripped automatically). Runtime auto-appends mins if omitted.

List Actions

Key Action
enter View full JSON details of selected movie
e Edit selected movie
d Delete selected movie (with confirmation)
c Clear all filters and reset to defaults
ctrl+r Refresh the current view
← / β†’ Previous / next page

Example session:

  Movies List (Filters: genres=drama)

   ID     Title                          Year    Runtime     Genres
  ───────────────────────────────────────────────────────────────────
   2      Inglourious Basterds           2009    153 mins    adventure, drama, war
   1      The Departed                   2006    151 mins    crime, drama, thriller

  Page 1 of 1 (2 records total)

  enter: details β€’ esc: back β€’ t/g/y/r/i: search β€’ c: clear β€’ ctrl+r: refresh β€’ d: delete β€’ e: edit β€’ ←/β†’: page

5. Movie Details (JSON View)

Press enter on any movie in the list to see the full raw JSON response from GET /v1/movies/:id:

  Movie Details (#2)

  {
    "movie": {
      "id": 2,
      "title": "Inglourious Basterds",
      "year": 2009,
      "runtime": "153 mins",
      "genres": [
        "adventure",
        "drama",
        "war"
      ],
      "version": 1
    }
  }

  esc: back β€’ ctrl+c: quit

6. Add / Edit a Movie

Both forms share the same layout with four fields:

  Add New Movie

  > Title
    Year (e.g. 2024)
    Runtime (e.g. "102 mins")
    Genres (comma separated)

  esc: back β€’ tab: next β€’ enter: submit β€’ ctrl+c: quit
  • Add New Movie: All fields start empty. Submitting sends POST /v1/movies.
  • Edit Movie: Fields are pre-filled with the current movie data. On submit, you'll see a confirmation prompt: Are you sure you want to save these changes? (y/n). The edit sends PATCH /v1/movies/:id.

Runtime formatting: You can enter just the number (e.g. 102) and the client will automatically append mins.


7. Health Check

View the current status of the connected Greenlight API:

  Health Check

  Status:       available
  Environment:  production
  Version:      1.0.0

  esc: back β€’ ctrl+c: quit

8. Account Settings

View your profile and manage your account:

  Account Settings

> 1. Reset Password
  2. Logout

  esc: back β€’ ctrl+c: quit

Build Commands

The project includes a comprehensive Justfile:

Command Description
just run Run in development mode
just build Build binary to ./bin/client
just build-release Build optimized binary (stripped symbols)
just build-linux Cross-compile for linux/amd64
just test Run all tests
just lint Run golangci-lint
just audit Full quality check (tidy, vet, staticcheck, race tests)
just fmt Format all Go code
just clean Remove build artifacts

Project Structure

greenlight-client/
β”œβ”€β”€ cmd/cli/
β”‚   └── main.go              # Application entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ client.go         # HTTP client with auth token management
β”‚   β”‚   β”œβ”€β”€ auth.go           # Login, token handling
β”‚   β”‚   β”œβ”€β”€ movies.go         # Movie CRUD + raw JSON fetching
β”‚   β”‚   β”œβ”€β”€ users.go          # Register, activate, password reset, healthcheck
β”‚   β”‚   └── models.go         # Data structures (Movie, Metadata, etc.)
β”‚   └── ui/
β”‚       β”œβ”€β”€ model.go           # Main BubbleTea model & state machine router
β”‚       β”œβ”€β”€ styles/styles.go   # Centralized lipgloss styles
β”‚       β”œβ”€β”€ set_url.go         # API URL input & health verification
β”‚       β”œβ”€β”€ onboarding.go      # Auth menu (login/register/activate/forgot)
β”‚       β”œβ”€β”€ login.go           # Login form
β”‚       β”œβ”€β”€ register.go        # Registration form
β”‚       β”œβ”€β”€ activate.go        # Account activation form
β”‚       β”œβ”€β”€ forgot_password.go # Password reset request
β”‚       β”œβ”€β”€ reset_password.go  # Password reset with token
β”‚       β”œβ”€β”€ dashboard.go       # Main dashboard menu
β”‚       β”œβ”€β”€ healthcheck.go     # Health check display
β”‚       β”œβ”€β”€ account_settings.go# Account settings & logout
β”‚       β”œβ”€β”€ movie_list.go      # Movie table with search & pagination
β”‚       β”œβ”€β”€ movie_detail.go    # Raw JSON movie viewer
β”‚       β”œβ”€β”€ movie_edit.go      # Pre-filled movie editor with confirmation
β”‚       └── movie_form.go      # New movie creation form
β”œβ”€β”€ Justfile                   # Build & development commands
β”œβ”€β”€ API_CLIENT_GUIDE.md        # Greenlight API reference
└── go.mod

About

A beautiful, interactive terminal-based client for the Greenlight API, built with BubbleTea and Lip Gloss.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors