Skip to content

Intro-iu/hintly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Hintly

An AI-powered command-line tool to automate terminal tasks.

Hintly is a simple command-line tool written in Rust that helps automate the process of running terminal commands. It uses an AI model to generate shell commands based on user input and allows for executing or copying the generated commands. This tool can be particularly useful for automating common tasks or simplifying the execution of commands that may require specific syntax.

Rust License: MIT OpenAI

✨ Features

  • 🤖 AI-generated shell commands: Based on your prompt, the tool generates commands to execute in your terminal.
  • 🔄 Multiple operations: You can choose to run the generated command or copy it to your clipboard for manual execution.
  • 🌍 Cross-platform support: Works on Windows (via PowerShell) and Unix-based systems (via Shell).
  • 🔒 Configuration management: Stores API keys and other configuration details in a TOML file.

📦 Installation

cargo install --git https://github.com/Intro-iu/hintly.git

⚙️ Configuration

Upon installation, Hintly will try to create a configuration file named config.toml in your system's configuration directory if it doesn't exist:

  • On Unix-based systems: ~/.config/hintly/config.toml
  • On Windows: C:\Users\username\AppData\Roaming\hintly\config.toml

The configuration file contains three key fields:

  • api_key: Your API key to access the service (e.g., OpenAI API or similar).
  • base_url: The base URL for the API.
  • model: The model that you wanna use (e.g., GPT-4).

The tool will prompt you to enter these values if the configuration file is not present.

🚀 Usage

The basic syntax for using Hintly is:

hintly <prompt> [operation]
  • <prompt>: The requirement or task description from the user.
  • [operation] (optional): The operation to perform on the generated command. Available options are:
    • r or run: Run the generated command immediately.
    • c or copy: Copy the generated command to your clipboard.
    • If no operation is specified, the tool will prompt you to choose an operation.

🔧 Example

  1. Generating and running a command:

    hintly "List all files in the current directory" r
  2. Generating and copying a command:

    hintly "Show the system's uptime" c
  3. Interactive mode (if no operation is provided, the tool will ask for input):

    hintly "Create a new directory called 'test'"
    Enter your operation [r(un) | c(opy) | q(uit)]: r

🛠️ Operations

  • Run operation (r or run): Executes the generated command in the terminal using the appropriate shell (PowerShell for Windows, sh for Unix-based systems).
  • Copy operation (c or copy): Copies the generated command to your clipboard for manual execution.
  • Quit operation (q or quit): Exits the tool.

🗂️ Code Structure

  • main.rs: Contains the entry point of the application and handles the command-line interface (CLI) logic. It processes user input, calls the client to generate commands, and runs or copies the commands.
  • utils.rs: Contains utility functions for managing configuration files, including reading and writing the configuration (e.g., API keys and base URLs).
  • client.rs: Contains the Client struct which interfaces with the backend API to generate terminal commands based on user input. It sends a request with the prompt and receives a response with the corresponding shell command.

📦 Dependencies

  • clap: Used for building the CLI interface.
  • clipboard-rs: Provides functionality to interact with the system clipboard.
  • reqwest: Used for making HTTP requests to the API.
  • serde and serde_json: For serializing and deserializing configuration and API request/response data.
  • tokio: Async runtime for handling asynchronous tasks.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


⚠️ Note

Make sure to have your API key and base URL configured correctly in the config.toml file for the tool to function properly.

About

A Command-line Tool To Generate Commands Using LLM AIs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages