diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 840b7a8..1c903eb 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..1397271 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Written in Rust 🦀, because why not? ## 💻 Usage +### Prepare To get started, prepare two text files: 1. **Words to Link Together** - Contains the words from your own team. @@ -21,7 +22,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..863e6af 100644 --- a/src/configs/config.rs +++ b/src/configs/config.rs @@ -51,7 +51,11 @@ 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