typing-game-cli 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ import compose from 'just-compose';
7
7
  import filter from 'just-filter-object';
8
8
  import App from './app.js';
9
9
  import { config } from './config.js';
10
+ import { getBestWpmResult, getGoal, wasGoalAchieved } from './helpers.js';
10
11
  const cli = meow(`
11
12
  Usage
12
13
  $ typing-game-cli
@@ -29,6 +30,8 @@ const cli = meow(`
29
30
  --all-history Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
30
31
  --topic Use sentences from works written by specified author
31
32
  --top-n Display top n results in displaying results mode
33
+ --set-goal Set a goal (in wpm) that you wish to achieve
34
+ --goal-achieved Let you know whether a goal was achieved
32
35
 
33
36
  Short flags and aliases for options:
34
37
  --against-my-best: -b, --best, --my-best, --myself, --against-my-best-result
@@ -44,6 +47,8 @@ const cli = meow(`
44
47
  --top-n: --top
45
48
  --handicap --ha, --hndcp, --hdc, --han
46
49
  --handicap-count --hanco, --hanCo, --hndco, --haco
50
+ --set-goal --sgoal, --goal
51
+ --goal-achieved --goalach, --coolprogress, --progone, --goaldone, --aic
47
52
 
48
53
 
49
54
  Examples
@@ -63,6 +68,9 @@ const cli = meow(`
63
68
  $ typing-game-cli -r -s="-wpm" -a
64
69
  $ typing-game-cli --topic mark-twain
65
70
  $ typing-game-cli --topic ambrose-bierce
71
+ $ typing-game-cli --set-goal 60
72
+ $ typing-game-cli --goal 60
73
+ $ typing-game-cli --goal-achieved
66
74
  `, {
67
75
  importMeta: import.meta,
68
76
  flags: {
@@ -91,6 +99,14 @@ const cli = meow(`
91
99
  type: 'number',
92
100
  aliases: ['hanco', 'hanCo', 'hndco', 'haco']
93
101
  },
102
+ setGoal: {
103
+ type: 'string',
104
+ aliases: ['sgoal', 'goal']
105
+ },
106
+ goalAchieved: {
107
+ type: 'boolean',
108
+ aliases: ['goalach', 'coolprogress', 'progrone', 'progone', 'goaldone', 'aic']
109
+ },
94
110
  displayResults: {
95
111
  type: 'boolean',
96
112
  shortFlag: 'r',
@@ -141,6 +157,24 @@ if (cli.flags.clearResults) {
141
157
  config.clearAll();
142
158
  exitNow();
143
159
  }
160
+ if (cli.flags.setGoal) {
161
+ config.appendGoal(cli.flags.setGoal);
162
+ exitNow();
163
+ }
164
+ if (cli.flags.goalAchieved) {
165
+ const achiemenceResult = wasGoalAchieved();
166
+ if (achiemenceResult === null) {
167
+ console.log(`There are no goal yet. First set a goal by --set-goal [wpm] command`);
168
+ } else {
169
+ let messageToSay = achiemenceResult ? `Congrats, you have achieved your goal.` : `You goal is not achieved yet.`;
170
+ if (!achiemenceResult) {
171
+ const bestResult = getBestWpmResult();
172
+ messageToSay += ` Best result - ${bestResult.value.wpm}, goal - ${getGoal()}. Keep trying, don't give up!`;
173
+ }
174
+ console.log(messageToSay);
175
+ }
176
+ exitNow();
177
+ }
144
178
  const robotLevel = compose(flags => pick(flags, ['extraFast', 'fast', 'medium', 'low']), flags => filter(flags, (_, value) => value), flags => Object.keys(flags)[0] || 'medium')(cli.flags);
145
179
  const {
146
180
  handicap,
package/dist/config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import { join } from 'node:path';
4
+ import { formatISO } from 'date-fns';
4
5
  const defaultConfig = {};
5
6
  export default class Config {
6
7
  constructor() {
@@ -29,10 +30,27 @@ export default class Config {
29
30
  ...previous,
30
31
  ...entry
31
32
  }, null, 4);
32
- fs.writeFileSync(this._configFile, data, 'utf8');
33
+ this.persist(data);
34
+ }
35
+ appendGoal(wpm) {
36
+ const previous = this.get();
37
+ const currentGoals = previous.goals || [];
38
+ currentGoals.push({
39
+ wpm,
40
+ date: formatISO(new Date())
41
+ });
42
+ const data = JSON.stringify({
43
+ ...previous,
44
+ goals: currentGoals,
45
+ goal: wpm
46
+ }, null, 4);
47
+ this.persist(data);
33
48
  }
34
49
  clearAll() {
35
- fs.writeFileSync(this._configFile, '{}', 'utf8');
50
+ this.persist('{}');
51
+ }
52
+ persist(data) {
53
+ fs.writeFileSync(this._configFile, data, 'utf8');
36
54
  }
37
55
  }
38
56
  export const config = new Config();
package/dist/helpers.js CHANGED
@@ -225,6 +225,22 @@ const getResults = ({
225
225
  }
226
226
  return result;
227
227
  };
228
+ const getGoal = () => {
229
+ const config = new Config();
230
+ const data = config.get();
231
+ return data.goal;
232
+ };
233
+ const wasGoalAchieved = () => {
234
+ const goal = getGoal();
235
+ if (goal) {
236
+ const bestResult = getBestWpmResult();
237
+ if (bestResult === undefined) {
238
+ return false;
239
+ }
240
+ return goal <= bestResult.value.wpm;
241
+ }
242
+ return null;
243
+ };
228
244
  const getBestResult = () => {
229
245
  const config = new Config();
230
246
  const data = config.get();
@@ -291,4 +307,4 @@ const registerBestFrames = (config, frames) => {
291
307
  bestFrames: frames
292
308
  });
293
309
  };
294
- export { getDefaultSuite, getStatusVariant, getSentencesSkippingWords, getHaLeft, getHaCount, getWpmTextColor, getScoreTextColor, getMessage, getMessageOrPlaceholder, getBorderColor, getRobotBorderColor, getIntervalMs, isFinished, isWordTyped, isLastNumber as isLastNum, isAboutToFinish, calculateWPM, calculateCPS, calculateCPM, getCompetitionResult, getTypingWord, getRemainingPart, getResults, getBestResult, getBestResultCompactString, getBestFrames, getOpponentFrames, getResultByWordCount, getBestWpmResult, getSortedByString, getWordCount, getSuiteByTopic, registerResult, registerBestFrames };
310
+ export { getDefaultSuite, getStatusVariant, getSentencesSkippingWords, getHaLeft, getHaCount, getWpmTextColor, getScoreTextColor, getMessage, getMessageOrPlaceholder, getBorderColor, getRobotBorderColor, getIntervalMs, getGoal, isFinished, isWordTyped, isLastNumber as isLastNum, isAboutToFinish, calculateWPM, calculateCPS, calculateCPM, getCompetitionResult, getTypingWord, getRemainingPart, getResults, getBestResult, getBestResultCompactString, getBestFrames, getOpponentFrames, getResultByWordCount, getBestWpmResult, getSortedByString, getWordCount, getSuiteByTopic, registerResult, registerBestFrames, wasGoalAchieved };
@@ -0,0 +1,11 @@
1
+ {
2
+ "sentences": [
3
+ "When Don Diego de - I forget his name - the inventor of the last new Flying Machines, price so many francs for ladies, so many more for gentlemen - when Don Diego, by permission of Deputy Chaff-wax and his noble band, shall have taken out a Patent for the Queen's dominions. At present, my reliance is on the South-Eastern Railway Company, in whose Express Train here I sit, at eight of the clock on a very hot morning, under the very hot roof of the Terminus at London Bridge, in danger of being 'forced' like a cucumber or a melon, or a pine-apple.",
4
+ "And talking of pine-apples, I suppose there never were so many pine-apples in a Train as there appear to be in this Train. The hot-house air is faint with pine-apples. Every French citizen or citizeness is carrying pine-apples home. The compact little Enchantress in the corner of my carriage (French actress, to whom I yielded up my heart under the auspices of that brave child, 'MEAT-CHELL,' at the St. James's Theatre the night before last) has a pine-apple in her lap.",
5
+ "Compact Enchantress's friend, confidante, mother, mystery, Heaven knows what, has two pine-apples in her lap, and a bundle of them under the seat. Tobacco-smoky Frenchman in Algerine wrapper, with peaked hood behind, who might be Abd-el- Kader dyed rifle-green. Tall, grave, melancholy Frenchman, with black Vandyke beard, and hair close-cropped, with expansive chest to waistcoat, and compressive waist to coat: saturnine as to his pantaloons, calm as to his feminine boots, precious as to his jewellery, smooth and white as to his linen.",
6
+ "If I were to be kept here long, under this forcing-frame, I wonder what would become of me - whether I should be forced into a giant, or should sprout or blow into some other phenomenon! Compact Enchantress is not ruffled by the heat - she is always composed, always compact. O look at her little ribbons, frills, and edges, at her shawl, at her gloves, at her hair, at her bracelets, at her bonnet, at everything about her! How is it accomplished? What does she do to be so neat? How is it that every trifle she wears belongs to her, and cannot choose but be a part of her?",
7
+ "And even Mystery, look at her! A model. Mystery is not young, not pretty, though still of an average candle-light passability; but she does such miracles in her own behalf, that, one of these days, when she dies, they'll be amazed to find an old woman in her bed, distantly like her. She was an actress once, I shouldn't wonder, and had a Mystery attendant on herself.",
8
+ "Perhaps, Compact Enchantress will live to be a Mystery, and to wait with a shawl at the side-scenes, and to sit opposite to Mademoiselle in railway carriages, and smile and talk subserviently, as Mystery does now. That's hard to believe! Two Englishmen, and now our carriage is full. First Englishman, in the monied interest - flushed, highly respectable - Stock Exchange, perhaps - City, certainly."
9
+ ],
10
+ "tags": ["charles-dickens", "a-flight"]
11
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "sentences": [
3
+ "Kierkegaard identified three primary configurations the failure can take. The first and most common is the despair of ignorance - being in despair without knowing it. A person in this state has not yet noticed any gap between the life they are living and the life they were capable of living. Their attention is consumed by the routine surfaces of daily existence: work, possessions, social position, the consumption of entertainment.",
4
+ "The deeper question of what kind of person they are, in any meaningful sense, has never been seriously posed. Kierkegaard considered this unconscious form to be the dominant pattern in modern society - most people, in his view, were in despair without realising it, because the structures of their lives had insulated them from ever asking the question.",
5
+ "The second form is the despair of weakness - knowing what self one is meant to be and not being willing to be it. The person in this state has had some glimpse of their own possibilities and has, for whatever combination of fear, comfort, social pressure, or fatigue, declined to pursue them. The third form is the despair of defiance - willing to be a self other than the one one is, refusing the actual configuration of one’s life in favour of an imaginary or constructed alternative.",
6
+ "The defiant form, Kierkegaard thought, was the most acute but also the rarest. As one frequently-cited line from the book puts it: \"The greatest hazard of all, losing the self, can occur very quietly in the world, as if it were nothing at all. No other loss can occur so quietly; any other loss - an arm, a leg, five dollars, a wife, etc. - is sure to be noticed.\"",
7
+ "Kierkegaard was writing in 1849, in a theological framework, with no empirical methodology beyond his own observation of the people around him in nineteenth-century Copenhagen. His specific claims about despair as a sickness of the spirit cannot be tested in the same way an empirical hypothesis can be tested. What can be tested is whether the basic phenomenon he described - that the failures most haunting to people across a life are the failures to become the self one was capable of being - shows up in modern psychological data on regret.",
8
+ "The answer is that it does. Per a 2023 replication in Royal Society Open Science of the foundational research by Thomas Gilovich and Victoria Medvec at Cornell University, the empirical psychology of regret converges on a striking temporal pattern: in the short term, people’s most acute regrets tend to be about things they did and wish they had not done. In the long term, the pattern reverses.",
9
+ "The regrets that haunt people across years and decades, and that dominate when people look back on their lives as a whole, are overwhelmingly about things they did not do - chances not taken, paths not pursued, selves not allowed to emerge. Gilovich and Medvec’s original 1994 paper in the Journal of Personality and Social Psychology found this pattern across multiple population groups, including a sample of nursing-home residents reflecting on their entire lives.",
10
+ "The 2023 replication, conducted at a Chicago museum of psychological science with a large public sample, reproduced the temporal interaction even though the specific magnitudes differed. The pattern is now considered one of the more robust findings in the empirical literature on regret. Its philosophical implication aligns closely with Kierkegaard’s framework, even though the researchers involved generally do not cite him.",
11
+ "The most disconcerting feature of Kierkegaard’s account is his insistence that this despair is, in its most common form, undetectable to the person carrying it. Unlike acute sadness, which announces itself, the unconscious form of despair tends to be hidden by the very busyness of life that produces it. A person fully occupied with work, family obligations, consumption of news and entertainment, social media, the small daily tasks of contemporary existence, is unlikely to encounter the question of whether they are actually becoming the self they were meant to be.",
12
+ "The question requires solitude, reflection, and a degree of confrontation with one’s own choices that ordinary life does not generally provide. As reported in D. Anthony Storm’s commentary on The Sickness Unto Death, Kierkegaard described despair as a “misrelation in the relation of a synthesis that relates itself to itself” — a sickness that, unlike most diseases, the patient is largely responsible for and from which the patient cannot escape simply by avoiding awareness of it. The avoidance, in Kierkegaard’s framework, is itself part of the despair.",
13
+ "Intellectual honesty requires noting what Kierkegaard’s account does not establish. It is not a recipe for happiness. It does not specify what self any given person was meant to become, or how to identify that self, or how to pursue it once identified. Kierkegaard’s own answer to the question of how despair is overcome was specifically Christian — through a particular relation to God that he called faith — and many modern readers find that the theological framing limits the framework’s applicability.",
14
+ "The diagnostic side of his work, however, has had broad influence well beyond the specifically Christian context, including on the existentialist philosophers of the twentieth century, on the founders of existential psychotherapy, on Erik Erikson’s developmental concept of “integrity versus despair” in late life, and on the broader twentieth-century literature on authenticity and self-realisation.",
15
+ "What the framework provides is a vocabulary for naming a condition that often goes unnamed — the slow recognition, late in a life, that the person one has been is not quite the person one started out hoping to be. Kierkegaard called this the breaking through of despair into consciousness, and he thought it was, paradoxically, a kind of progress. The unconscious form, in his account, was worse than the conscious form, because it left no opening for change."
16
+ ],
17
+ "tags": ["soren-kierkegaard", "about-despair"]
18
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typing-game-cli",
3
3
  "description": "Command line game to practice your typing speed by competing against typer-robot or against your best result",
4
- "version": "7.0.0",
4
+ "version": "7.2.0",
5
5
  "homepage": "https://github.com/akgondber/typing-game-cli",
6
6
  "repository": "akgondber/typing-game-cli",
7
7
  "author": "Rushan Alyautdinov <akgondber@gmail.com>",
@@ -114,6 +114,7 @@
114
114
  "typingpracrice",
115
115
  "bestresult",
116
116
  "terminalgame",
117
- "cligame"
117
+ "cligame",
118
+ "typingspeed"
118
119
  ]
119
120
  }
package/readme.md CHANGED
@@ -28,13 +28,15 @@ $ npm install --global typing-game-cli
28
28
  --medium Start a round with a robot having medium typing speed.
29
29
  --low Start a round with a robot having low typing speed.
30
30
  --handicap Start a round with handicap given by opponent to you by specified count of chars
31
- --handicap-count How many chars you wish to ask from opponent
31
+ --handicap-count How many chars you wish to ask from opponent
32
32
  --display-results Show cpm and wpm results
33
33
  --sort-by Sort results by specified value (-cpm, cpm, -wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
34
34
  --all-hostory Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
35
35
  --compact-result Display top result in compact format
36
36
  --topic Use sentences from works written by specified author
37
37
  --top-n Display top n results when `--display-results` is being used
38
+ --set-goal Set a goal (in wpm) that you wish to achieve
39
+ --goal-achieved Let you know whether a goal was achieved
38
40
 
39
41
  Short flags and aliases for options:
40
42
  --against-my-best: -b, --best, --my-best, --myself, --against-my-best-result
@@ -49,6 +51,10 @@ $ npm install --global typing-game-cli
49
51
  --compact-result --cmpc
50
52
  --topic --author
51
53
  --top-n --top
54
+ --handicap --ha, --hndcp, --hdc, --han
55
+ --handicap-count --hanco, --hanCo, --hndco, --haco
56
+ --set-goal --sgoal, --goal
57
+ --goal-achieved --goalach, --coolprogress, --progone, --goaldone, --aic
52
58
 
53
59
 
54
60
  Examples
@@ -108,6 +114,12 @@ $ tgc -b
108
114
 
109
115
  ![](media/display-top-n-results.png)
110
116
 
117
+ #### Useful links
118
+
119
+ [How to type fast (from someone who types 145 words per minute)](https://www.reddit.com/r/productivity/comments/m40www/how_to_type_fast_from_someone_who_types_145_words/)
120
+ [10 Tips for Improving Your Typing Speed and Accuracy](https://www.geeksforgeeks.org/blogs/tips-improving-your-typing-speed-accuracy/)
121
+ [5 Tips for Improving Your Typing Speed & Accuracy](https://www.herzing.edu/blog/5-tips-improving-your-typing-speed-accuracy)
122
+
111
123
  ## License
112
124
 
113
125
  MIT © [Rushan Alyautdinov](https://github.com/akgondber)