diff --git a/README.md b/README.md index ff215ab..88ec3c7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ from cloned github repository. Without any argument program waits for user to en `python3 -m fasttyper example_text.txt` -Program also allows user to pipe text into it. Keep in mind, it only supports spaces and new line characters, so you won't be able to table tabs. For example, you can run _Fasttyper_ on rfurtune generated quote changing tabulators to spaces with sed: +Program also allows user to pipe text into it. Keep in mind, it only supports spaces and new line characters, so you won't be able to table tabs. For example, you can run _Fasttyper_ on fortune generated quote changing tabulators to spaces with sed: -`rfurtune | sed 's/\t/ /g' | python3 -m fasttyper` +`furtune | sed 's/\t/ /g' | python3 -m fasttyper` # Known issues diff --git a/doc/example_config.json b/doc/example_config.json index eeea41d..e47deb2 100644 --- a/doc/example_config.json +++ b/doc/example_config.json @@ -5,5 +5,5 @@ "stats_template": "\n\nwpm: {stats.wpm}\ntime: {stats.total_seconds}s", "stats_color": 5, "summary_template": "WPM: {stats.wpm}\nCPM: {stats.cpm}\nRAW WPM: {stats.raw_wpm}\nRAW CPM: {stats.raw_cpm}\ntotal seconds: {stats.total_seconds}\ntotal minutes: {stats.total_minutes}\ncorrect words: {stats.correct_words}\ncorrect chars: {stats.correct_chars}\nincorrect words: {stats.incorrect_words}\nincorrect chars: {stats.incorrect_chars}\ntotal words: {stats.total_words}\ntotal chars: {stats.total_chars}\naccuracy: {stats.accuracy}%", - "summary_datafile": "~/.config/cache/fasttyper/datafile.csv" -} \ No newline at end of file + "summary_datafile": "~/.cache/fasttyper/datafile.csv" +} diff --git a/fasttyper/__main__.py b/fasttyper/__main__.py index 9f0e233..9806f91 100644 --- a/fasttyper/__main__.py +++ b/fasttyper/__main__.py @@ -43,7 +43,7 @@ def main(): parser = argparse.ArgumentParser() if is_tty: - parser.add_argument("file", metavar="FILE") + parser.add_argument("file", metavar="FILE", help="file to type") parser.add_argument( "--config", diff --git a/fasttyper/config.py b/fasttyper/config.py index 9fdbc32..fb55c3e 100644 --- a/fasttyper/config.py +++ b/fasttyper/config.py @@ -20,7 +20,7 @@ class Config: "total chars: {stats.total_chars}\n" "accuracy: {stats.accuracy}%" ), - "summary_datafile": "~/.config/cache/fasttyper/datafile.csv", + "summary_datafile": "~/.cache/fasttyper/datafile.csv", } def __init__(self, configmap): diff --git a/fasttyper/stats.py b/fasttyper/stats.py index 8400c25..cd2ac19 100644 --- a/fasttyper/stats.py +++ b/fasttyper/stats.py @@ -110,10 +110,14 @@ class Stats: record = self.produce_record() - with open(datafile, "w") as f: - writter = csv.DictWriter(f, fieldnames=record.keys()) - - if not exists: + if not exists: + with open(datafile, "w") as f: + writter = csv.DictWriter(f, fieldnames=record.keys()) writter.writeheader() + writter.writerow(record) + else: + with open(datafile, "a") as f: + writter = csv.DictWriter(f, fieldnames=record.keys()) + writter.writerow(record) - writter.writerow(record) + print(f"\nwrote stats to {datafile}")