Rust

Power up CLI tools with natural language

Build a universal utility that transforms natural language tasks into precise command-line arguments.

⏱️ 2h 15min
πŸ“¦ 4 modules
🎯 Beginner

What You'll Build

You'll build a universal command-line companion that understands natural-language requests and turns them into the exact arguments for the tool you're already using. Say β€œdrop the last commit” while invoking it for Git and it proposes git reset --soft HEAD^, ready to run.

The utility works as a plus-suffixed wrapper you can call alongside your everyday commands (think git+, ffmpeg+, rg+), always showing a clear preview and asking for confirmation before executing. It makes powerful actions quick, transparent, and safe.

Learning Objectives

  • Build a universal wrapper CLI in Rust

  • Integrate LLM workflows using rig-core and OpenAI

  • Design effective prompt templates for arguments

  • Implement async command execution with Tokio

  • Create interactive confirmations with dialoguer

  • Manage robust errors and exits with anyhow

Prerequisites

  • Basic Rust syntax, ownership, and borrowing

  • Basic command-line and environment variables

  • Familiarity with async/await concepts

  • Rust toolchain and cargo installed

  • OpenAI API key

Course Modules

1

Binary Setup and Parsing

Create a binary crate and add anyhow for easy errors. Extract command name and combine remaining args into natural text.

2

Prompt to Parameters

Build a reusable prompt that outputs only command parameters. Call the model via rig-core with tokio async.

3

Confirm Command Execution

Confirm command execution using dialoguer. Execute the process with tokio, inherit I/O, return exit code.

4

Release Build and Alias

Compile the release binary and place it in your bin. Create a git+ alias, set OpenAI OPENAI_API_KEY, then run commands.