Rust

Power up CLI tools with natural language

New

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

⏱️ 2h 30min
📦 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.

Power up CLI tools with natural language cover

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

Assembly Steps

1

Binary Setup and Parsing

Create the CLI binary structure, parse command-line arguments, and extract the tool name and user request.

2

Prompt to Parameters

Build prompt templates and integrate with OpenAI via rig-core. Use Tokio for async execution.

3

Confirm Command Execution

Add interactive confirmation with dialoguer, display the proposed command, and execute on approval.

4

Release Build and Alias

Create optimized release build, set up shell aliases for plus-suffixed commands, and test with real tools.

Technologies

Rust Cargo Tokio Anyhow rig-core OpenAI Dialoguer LLM Prompt Engineering CLI