Sweet
The Software Engineer's Exercise for Typing
Install / Use
/learn @NicksPatties/SweetREADME
Sweet
Hey! That's
,gg, gg
i8""8i I8 ,gg,
`8,,8' I8 i88i
`88' 88888888 i88i
dP"8, I8 i88i
dP' `8a gg gg gg ,ggg, ,ggg, I8 ,gg,
dP' `Yb I8 I8 88bg i8" "8i i8" "8i I8 gg
_ ,dP' I8 I8 I8 8I I8, ,8I I8, ,8I ,I8,
"888,,____,dP,d8, ,d8, ,8I `YbadP' `YbadP' ,d88b, aa
a8P"Y88888P" P""Y88P""Y88P" 888P"Y888888P"Y88888P""Y88 88
<!--toc:start-->
- Sweet
- Contributor instructions
What is Sweet?
Sweet is a Software Engineering Exercise for Typing. In other words, it's a touch typing exercise command line interface specifically designed for programmers.
Installation
Using go
Assuming you have go installed, you can use the following command:
go install github.com/NicksPatties/sweet@latest
Downloading an executable
-
Go to the releases page.
-
Download the executable with the matching operating system and architecture in the file name and its corresponding checksum file. The executables in the release are shown in the format
sweet-<os>-<architecture>. -
Verify your downloaded executable using the
sha256sumcommand. Note that the checksum and the executable should be in the same directory and have the same basename.
# with <sweet_executable> and <sweet_executable>.sha256 in the current dir
sha256sum <sweet_executable>.sha256 --check
# <sweet_executable>: OK
If the checksums do not match, do not run the file. Please report an issue if something is wrong.
- Use
chmodto make the executable actually executable.
chmod u+x <sweet_executable>
- Move the executable to a directory that is included in your
$PATH, and rename it tosweet.
mv <sweet_executable> <somewhere_on_path>/sweet
You're now ready to use sweet!
Via your system's package manager
Usage
sweet - Run a typing exercise
sweet

This runs a random exercise from sweet's exercises directory. Once complete, you'll see the results of your exercise. Here's an example:

Once complete, the stats for the repetition will be saved in an SQLite database. By default, the database is located in $HOME/.config/sweet/sweet.db.
Adding new exercises
By default, exercises are located in $HOME/.config/sweet/exercises. If this directory doesn't exist, it will be created, and some default exercises will be added.
Add more files to the exercises directory if you'd like to include them in the random exercise rotation!
Using a specific language
sweet -l [extension]
Selects a random file within the exercises directory that matches a given extension. If no matching extension is found, then the program ends with an error.
With a different exercises directory
Use the $SWEET_EXERCISES_DIR environment variable.
$SWEET_EXERCISES_DIR="~/.exercises" sweet
With a specific file
sweet [file]
If your file is really large, use the -s and -e flags to select the starting and ending lines of the exercise, respectively.
sweet [really-large-file] -s 100 -e 110
Using piped input
Use the - filename to create an exercise with standard input.
curl https://nickspatties.com/main.go | sweet -
You can still use the -s and -e flags if you want to filter your exercise input.
curl https://raw.githubusercontent.com/NicksPatties/sweet/refs/heads/main/cmd/root/sweet.go | sweet - -s 381 -e 385
sweet stats - Print typing exercise statistics
sweet stats

For the past two weeks
sweet stats --since=2w
- You can also query by hours (
h), days (d), months (m), and years (y)
Using a date range
sweet stats --start=YYYY-MM-DD --end=YYYY-MM-DD
For specific programming languages
For Go:
sweet stats --lang=go
For Python:
sweet stats --lang=py
For specific exercises
To see all the stats for the past day for the exercise hello.go:
sweet stats --name=hello.go
You can also use the * wildcard to perform a partial match. For instance:
sweet stats --name=hello*
- This will match all exercises that have the name "hello" at the beginning
View specific metrics
By default, you'll see the wpm, raw wpm, accuracy, errors, and mistakes when you query your stats.
If you'd only like to see specific metrics, pass the flags of the stats. For example, this will show the wpm and mistakes columns.
sweet stats --wpm --miss
Contributions
If you notice any bugs, or have general feedback regarding your experience using sweet, please post an issue in our GitHub repo. You may also email me at nickspatties@proton.me.
Wanna contribute a change to the code? Please fork the repository, and then submit a pull request!
License
Contributor instructions
Running the application
go build .
./sweet
Testing
Running unit tests for a module
go test ./{{module-name}}
Running unit tests for all modules
go test ./...
Building and reviewing test coverage
go test -coverprofile coverage {{module-path}} && go tool cover -html=coverage
For example, building the coverage profile, building the html page, and then running it with a browser:
go test -coverprofile c.out ./cmd/root && go tool cover -html=c.out -o c.html && {{your-browser}} c.html
Building a release version
Creates a release to GitHub, and updates the pkg.go.dev listing.
# Assuming you're currently on the commit you'd like to release
git checkout main
git tag {{version}}
git push origin {{version}}
./release
Creating a new command
- Create new file called
{{command}}/{{command}}.go
package {{command}}const CommandName = "{{command}}"
- Create a function in new file called
Run
- should return an int
- should accept
[]stringas first parameter for args - should accept any other inputs it needs
- (optional) Add
{{command}}Cmdvariable of type*flags.FlagSet - Create a test file
{{command}}/{{command}}_test.go - In
sweet.go, add func signature from step 2 toCommandsstruct - In
Runinsweet.go, add a case to theswitch subCommandstatement - In
Maininsweet.go, add theRunfunction from your new{{command}}module to thedefaultCommandsstruct. - Valiate flags in the
&cobra.Command's struct, then pass valid params to theRunfunction
By now you should have a new command that you can run and test like its own standalone application.
Writing e2e tests
See e2e/exercise_test.sh and e2e/e2e_test_template.sh for examples.
