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.
- 🤖 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.
cargo install --git https://github.com/Intro-iu/hintly.git
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.
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
orrun
: Run the generated command immediately.c
orcopy
: Copy the generated command to your clipboard.- If no operation is specified, the tool will prompt you to choose an operation.
-
Generating and running a command:
hintly "List all files in the current directory" r
-
Generating and copying a command:
hintly "Show the system's uptime" c
-
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
- Run operation (
r
orrun
): Executes the generated command in the terminal using the appropriate shell (PowerShell
for Windows,sh
for Unix-based systems). - Copy operation (
c
orcopy
): Copies the generated command to your clipboard for manual execution. - Quit operation (
q
orquit
): Exits the tool.
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 theClient
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.
- 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.
This project is licensed under the MIT License - see the LICENSE file for details.
Make sure to have your API key and base URL configured correctly in the config.toml
file for the tool to function properly.