From 1fc730ca49d3953589da6dfff984a9fa069db262 Mon Sep 17 00:00:00 2001 From: theoforger Date: Thu, 21 Nov 2024 14:12:58 -0500 Subject: [PATCH] Improve documentations --- CONTRIBUTING.md | 17 ++++------------- README.md | 30 +++++++++++++++++++++++++++--- src/configs/config.rs | 8 +++++++- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 840b7a8..77d3e51 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,19 +27,6 @@ git clone https://github.com/theoforger/mastermind.git cd mastermind ``` -### Configure Environment Variables - -Make a copy of [`example.env`](example.env) and name it `.env` - -```bash -cp example.env .env -``` - -Edit `.env` to add or modify: -- API key -- The base URL of an OpenAI-compatible API -- A default language model - ### Build the Project Run the following command: @@ -48,6 +35,10 @@ Run the following command: cargo build ``` +### Configure Environment Variables + +See: https://github.com/theoforger/mastermind?tab=readme-ov-file#-configure + ## ✒️ Linting / Code Formatting Before you commit, make sure the following linting/formatting tools using the options below. Commit only when your code is error/warning free. diff --git a/README.md b/README.md index 0c1f5c1..a6b9d88 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ Written in Rust 🦀, because why not? A gif demo of the basic functions of this program. -## 💻 Usage - +## 📖 Prepare To get started, prepare two text files: 1. **Words to Link Together** - Contains the words from your own team. @@ -21,7 +20,32 @@ To get started, prepare two text files: One word per line. Refer to the [`examples`](examples) directory for sample files. -Run the tool with: +## 🛠️ Configure +Here are what you need to configure before running mastermind: +- API key +- The base URL of an OpenAI-compatible API +- A default language model + +There are two ways to configure this program: +### Config File +During the first run, a config file will be created at your system's preferred location. The specific location will be given in the output. Generally, it is located at: +- For Linux: `$HOME/.config/mastermind/config.toml` +- For macOS: `$HOME/Library/Application Support/mastermind/config.toml` +- For Windows: `C:\Users\[your username]\AppData\Roaming\mastermind\config.toml` + +### Environment Variables +Make a copy of [`example.env`](example.env) and name it `.env` + +```bash +cp example.env .env +``` + +Then edit `.env` and provide you preferred configuration. + +Alternatively, you can simply pass these environment variables during run time. + + +## 🏃 Run ```bash mastermind [TO_LINK] [TO_AVOID] diff --git a/src/configs/config.rs b/src/configs/config.rs index adf31dc..1085338 100644 --- a/src/configs/config.rs +++ b/src/configs/config.rs @@ -51,7 +51,13 @@ impl Config { doc["model"]["default"] = value(""); // Write the document to the config file - println!("Config file not found or empty. Creating one..."); + println!( + "Looks like it's your first run\n\ + Creating a config file at {}\n\ + Make sure to modify it first or use the proper environment variables\n\ + See: https://github.com/theoforger/mastermind", + config_file.display() + ); fs::write(&config_file, doc.to_string())?; doc