Coder Social home page Coder Social logo

donkeytype's Introduction

Donkeytype

a very minimalistic cli typing test.

gif demonstrating how the program works

How it Works

When you run the program, you'll find the expected input displayed at the top of your terminal window. This text serves as a placeholder and represents what you should type when the test begins. Your goal is to type this text as quickly as possible. If you make a mistake, you can press the backspace key to delete a single character or hold down Option/Ctrl and press backspace to delete an entire word.

In the bottom-right corner of the screen, a helpful message prompts you to start the test by pressing 'e' (to enter the test) or exit by pressing 'q'.

While the test is running, you'll be able to monitor the time remaining in the bottom-left corner of the screen.

To pause the test, simply press <Esc>. To resume, press 'e' again.

Your WPM (words per minute) score is calculated based on the number of typed characters divided by 5 (word), and normalized to a 60-second timeframe (minute).

It was successfully tested on MacOS, Linux and Windows

Usage

Installation

Go to the latest release, download the compressed binary and unpack it locally. Then to run the main program with default configuration simply run the executable binary in your terminal:

./donkeytype

You can move the binary to e.g. ~/.local/bin folder (or any other folder added to your $PATH) to run it from anywhere:

mv ~/Downloads/donkeytype ~/.local/bin/donkeytype
donkeytype --version

By default donkeytype saves results of tests to ~/.local/share/donkeytype/donkeytype-results.csv on Linux and MacOS, and C:\Users\{Username}\AppData\Local\donkeytype\donkeytype-results.csv on Windows.

To view the history of results in a bar chart you can run:

./donkeytype history
picture demonstrating bar chart with history data

To see all available options run:

./donkeytype --help

Configuration

For now there are only three options that are read from config. Configuration will grow when more features are added (different modes, different languages, configuring colors).

Default config looks like this:

name default value type in JSON description
duration 30 number duration of the test in seconds
numbers false boolean flag indicating if numbers should be inserted in expected input
numbers_ratio 0.05 (if numbers=true) number ratio for putting numbers in the test
symbols false boolean flag indicating if symbols should be inserted in expected input
symbols_ratio 0.10 (if symbols=true) number ratio for putting symbols in the test
uppercase false boolean flag indicating if uppercase letters should be inserted in expected input
uppercase_ratio 0.15 (if uppercase=true) boolean ratio for putting uppercase letters in test
dictionary_path None (builtin dictionary) string path to file with dictionary words to sample from while creating test's expected input
save_results true boolean flag indicating if results should be saved to a file ( ~/.local/share/donkeytype/donkeytype-results.csv on Linux and MacOS, and C:\Users\{Username}\AppData\Local\donkeytype\donkeytype-results.csv on Windows)

NOTE: If provided numbers_ratio is not between 0 to 1.0, default numbers_ratio = 0.15 will be used. Same happens with uppercase_ratio and symbols_ratio.

You can provide this config as options when running the program like so:

./donkeytype --duration 60 --numbers true --uppercase true

To get all the available options run

./donkeytype --help

You can also put all the options inside config file in ~/.config/donkeytype/donkeytype-config.json:

{
    "duration": 60,
    "dictionary_path": "/usr/share/dict/words",
    "numbers": true,
    "numbers_ratio": 0.1,
    "uppercase": true,
    "uppercase_ratio": 0.3,
    "colors": {
        "correct_match_fg": "green",
        "correct_match_bg": "white",
        "incorrect_match_fg": "#ff00ff",
        "incorrect_match_bg": "#0f000f"
    }
}

Providing config in a file also supports passing custom color values.

Development

Prerequisites

You need to have rust toolchain installed locally to develop this program.

Getting started

Use cargo to compile and run local repository with:

cargo run

To pass configuration options pass them via cargo to underlying program using --:

cargo run -- --duration 60

Guidelines

Try cover your changes with unit tests whenever possible. Before opening a PR run locally rustfmt to format your changes and make sure tests are passing with cargo test.

Contributing

Thank you for considering contributing to the project.

Suggesting a Feature or Enhancement

If you have an idea for a new feature or enhancement, please share it. Follow these steps to suggest a feature:

  1. Check if your feature idea has already been proposed in the issue tracker.
  2. If it's not already there, open a new issue and describe the feature you'd like to see, why it's needed, and how you envision it working.

Codebase contribution

To submit a contribution, follow these general steps:

  1. Create your own fork of the code repository.
  2. Make the desired changes in your fork.
  3. Ensure your changes adhere to the code style and quality standards.

Hacktoberfest 2023

If you found this repo because of Hacktoberfest 2023, make sure you familiarize yourself with participation rules for contributors.

Uninstalling

If you want to remove donkeytype from your system you simply remove the executable binary from wherever you've downloaded it to.

MacOS & Linux

Additionally to remove the history of results run:

rm -rf ~/.local/share/donkeytype

and if you've created a configuration file remove it too:

rm -rf ~/.config/donkeytype

Windows

On Windows delete C:\Users\{Username}\AppData\Local\donkeytype folder to get rid of history results and configuration file.

License

MIT. See LICENSE

donkeytype's People

Contributors

0ky avatar aashirbadb avatar kritikash18 avatar lemorage avatar mdrokz avatar mercmayhem avatar milinddethe15 avatar phoffmeister avatar radlinskii avatar windowgenerator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

donkeytype's Issues

support configuring color scheme

Currently Colors are hardcoded (e.g. here), which might make it not really accessible for some users.
They work fine on my machine on light and dark mode, but that's only with my settings, and user should be able to adjust colors to her/his needs.

Test donkeytype on Linux

Would be nice to get it working on linux.
Theoretically paths used now for results files, and config file are unix compatible so it might just work.
If the program is successfully tested on Linux would be nice to create a release binary for linux in .github/workflows/release.yaml for it.

support providing numbers ratio in config

I've added option to put numbers inside the expected input of a test.
Currently the ratio for putting numbers is hardcode to 0.05 (see here)

The goal of this issue is to enable changing this ratio with config.
User should be able to pass numbers-ratio argument to the program or add it to his config file.
Values should be between floating point numbers between 0.0 to 1.0. Would be nice to also parse 0 and 1.

Documentation Missing Information on `save_results` Location

The README does not provide any information about where these results are stored if save_results flag is true. Only when I took some time to see the test_results.rs, can I find that the results are saved to a file located in the .local/share/donkeytype inside the user's home directory.

It would be more user-friendly if the README could be updated to include this information.

Count WPM only in words that were typed correctly

Currently WPM is calculated based on the correct characters.
What monkeytype does, and I think is cool is that they only count WPM in words that don't have any mistake in them.
Would be nice to try and use the same approach.
It would be much more important to not make any mistakes/ correct the mistakes, so I believe it would be beneficial from learning perspective.

Support non Ascii characters

This is required to be able to work with different languages than english.
Currently characters like ł, ń, ü, ß break the program because they take more than 1 byte of space inside a string.
We should add support for typing those characters.
This might require refactoring logic of checking character validity and/or displaying the character.

support uppercase letters at the beginning of words.

This could be a new option in the config.

I think the optimal behaviour would be to only make Uppercase letters at the beginning of some words (use ratio logic similar to how numbers are inserted currently).

Option to make whole words UPPERCASE might be a separate issue. (I wouldn't use it 😅, but feel free to create an issue and work on it if you'd like)

User should be able to set this flag as an argument or inside config file.
Default value should be false.

[Feature Request]: LAN Multiplayer

The idea is that if two ppl are running the app and are in the same network, they can challenge each other. They will have the same exact text on screen and will start typing as the count goes hits 3.

Down the road we could even add more options like words wil fall down and the two players will have t type the word before it reaches the ground. Whoever managed to shoot down more words to say, will win.

Thought this would be a fun addition to the project!

add argument for custom config file path

Similar to #47 add argument --config-path to specify custom path for config file to be read.
Document it with comment in main.rs and config.rs and add it to Readme.
Add information that this config file should still be .json
Make sure the tests are passing.

support symbols

Support symbols inside the expected input.
Could be set as different levels (basic interpunction, programming), or even support user providing a list of symbols that could be used.

This feature should work similar to adding numbers inside the expected input. Please have a look inside the source code to see how it happens that if you pass numbers=true you can get numbers as part of your test's expected input.

User should be able to set it as an argument when running the program or put it inside her/his config file.

Feature Request: Allow Custom Storage Locations for `save_results`

Currently, the save_results flag stores the results to ~/.local/share/donkeytype by default. It would be better to let the user customize the default location.

Proposed Solution:

  1. Introduce a new option, say --results-path, where users can provide their preferred storage location. If this option isn't set, the program can fall back to the default location.

  2. Alternatively, we could modify the save_results flag to accept an optional argument that specifies the storage location. If the argument isn't provided, it defaults to the current behavior.

add integration tests

I tried to add integration tests, but I've failed miserably. Maybe someone more experienced with working with CLI rust will have more luck than me. :)

save test results to csv

Would be really useful to save results of the test that has run into a file so that results can be displayed and compared later on.

This issue is only about writing to a file.
File location can be, ~/.config/donkeytype/results.csv, because this folder is already used for config file.
.csv seems to be the best extension for this purpose.
If the file doesn't exist it should be created.

Different values that are currently displayed in src/main.rs after the test is finished should be added as columns into the csv.
Information about settings should also be included, (currently only duration, and numbers if numbers where present). Later might be beneficial to have this data for filtering the results.

serde crate should be used for this purpose, it is already a dependency.

handle shortcuts for deleting last word from the input

On MacOS it makes a lot of sense to have <Alt>+<Backspace> deleting characters from current cursor position till beginning of the word (till white space character).
It might be easier to type a word again if there were any mistakes in it.

Add Arguments for Configuring Params in CLI

Currently, we need to adjust the value in the config file donkeytype-config.json manually (if we had one). Would it be nice that we can directly set and save these parameters in the CLI. For instance:

$ ./donkeytype config set duration 30
$ ./donkeytype config set uppercase true

Unlike the README examples like ./donkeytype --duration 60 --numbers true --uppercase true for on-the-fly configuration, this new option would allow us to persistently save these settings in the JSON configuration file.

read results from csv and display them

Once the results are saved in ~/.config/donkeytype/results.csv (see #2) it would be awesome to add a command for the program to show the results.

like:

cargo run -- stats

At first it would be okay to display them even as just a table of numbers, but in the long run, it would be perfect to see a chart made of WPM so user can see her/his progress over time. (tui rs has support of creating charts from what I saw https://github.com/fdehau/tui-rs)

Add support for Windows

Currently paths for results file and config file are hardcoded to ~/.local and ~/.config and they need to be changed to try to support Windows platform.
https://github.com/dirs-dev/dirs-rs is already in the project so it might be handy to use it.
But the paths that it uses are different than ~/.local and ~/.config for MacOS, which I'm not a big fan of. I would rather stick to those directories on MacOS still.

Than, once the paths are updated the program would need to be compiled for windows target and tested there.

Windows Double KeyPress Issue

On Windows, a single keypress is mistakenly detected twice: once on KeyDown and again on KeyUp.
This issue stems from crossterm, you will need to check the KeyEventKind:

if let Event::Key(key) = event {
    if key.kind == KeyEventKind::Press {
        ...
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.