Skip to content

Commit

Permalink
Merge branch 'main' into better-notation
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPlanche committed Feb 1, 2025
2 parents 80e130c + 54c8caa commit 8436948
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,44 @@ chess-tui -e /your/bin/path
Here I installed stockfish using homebrew and gave chess-tui the path the the engine binary.
This command will store in your home directory the chess engine path so you don't have to relink it everytime !

### Configuration

Chess-tui uses a TOML configuration file located at `~/.config/chess-tui/config.toml`. Here are the available configuration options:

```toml
# Path to the chess engine binary
engine_path = "/path/to/engine"

# Display mode: "DEFAULT" or "ASCII"
display_mode = "DEFAULT"

# Logging level: "Off", "Error", "Warn", "Info", "Debug", "Trace"
log_level = "Off"
```

#### Configuration Options:

- **engine_path**: Path to your UCI-compatible chess engine binary
- **display_mode**:
- `DEFAULT`: Uses unicode chess pieces
- `ASCII`: Uses ASCII characters for pieces
- **log_level**: Controls the verbosity of logging
- `Off`: No logging (default)
- `Error`: Only errors
- `Warn`: Warnings and errors
- `Info`: General information, warnings and errors
- `Debug`: Debugging information
- `Trace`: Very verbose debugging information

The config file is automatically created when you first run chess-tui. You can manually edit it to customize your experience.

Base config:
```toml
# no engine path
display_mode = "DEFAULT"
log_level = "Off"
```

### Documentation

You can find the documentation of the project [here](https://thomas-mauran.github.io/chess-tui/docs/intro)
Expand All @@ -84,4 +122,4 @@ You can find the roadmap of the project [here](https://github.com/users/thomas-m

### Crates.io

The project is also available on crates.io [here](https://crates.io/crates/chess-tui)
The project is also available on crates.io [here](https://crates.io/crates/chess-tui)
2 changes: 1 addition & 1 deletion src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn setup_logging(
fs::File::create(log_file)?,
)])?;

log::info!("Logging initialized at {} level", level);
log::info!("Logging initialized at {level} level");
Ok(())
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ fn main() -> AppResult<()> {
let folder_path = home_dir.join(".config/chess-tui");
let config_path = home_dir.join(".config/chess-tui/config.toml");

// Setup logging first thing
let default_log_level = LevelFilter::Off;
if let Err(e) = logging::setup_logging(&folder_path, &default_log_level) {
eprintln!("Failed to initialize logging: {}", e);
}

// Create the configuration file
config_create(&args, &folder_path, &config_path)?;

Expand Down Expand Up @@ -79,6 +73,11 @@ fn main() -> AppResult<()> {
println!("Error reading the file or the file does not exist");
}

// Setup logging
if let Err(e) = logging::setup_logging(&folder_path, &app.log_level) {
eprintln!("Failed to initialize logging: {}", e);
}

// Initialize the terminal user interface.
let terminal = ratatui::try_init()?;
let events = EventHandler::new(250);
Expand Down

0 comments on commit 8436948

Please sign in to comment.