radlinskii / donkeytype

typing test TUI app
MIT License
17 stars 15 forks source link

fix(paths): add os specific directory handling for windows #38

Closed 0Ky closed 1 year ago

0Ky commented 1 year ago

Adjusted the path generation in get_results_dir_path, handle_main_command, and setup_terminal functions to account for Windows-specific local config directory conventions using the cfg! macro.

This PR closes issue https://github.com/radlinskii/donkeytype/issues/37.

Below are paths for both the config & results files by OS.

Config file:

Windows: C:\Users\{Username}\AppData\Local\donkeytype\donkeytype-config.json Linux: /home/{Username}/.config/donkeytype/donkeytype-config.json MacOS: /Users/{Username}/.config/donkeytype/donkeytype-config.json

Results file:

Windows: C:\Users\{Username}\AppData\Local\donkeytype\donkeytype-results.csv Linux: /home/{Username}/.local/share/donkeytype/donkeytype-results.csv MacOS: /Users/{Username}/.local/share/donkeytype/donkeytype-results.csv

0Ky commented 1 year ago

Looks really clean 👏 Did you test it on Windows?

Running cargo test passes.

test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s

I've also conducted tests manually on Windows OS, the donkeytype-results.csv file is generated at the expected path after completing a type test and adding donkeytype-config.json file to the same path with custom configuration is interpreted correctly.