Habit tracker

This is a Go program that helps with establishing new, and tracking existing habits.
Description
When we're trying to establish a new habit (studying, running, rowing for example), it can be difficult to maintain focus and motivation. Studies suggest that it takes many weeks of regularly performing a new habit before it becomes natural and automatic. So, if you can motivate yourself to do the new habit every day for a month or two, that'll get you well on the way.
One thing that can help is to track your performance of the habit. Suppose you decide that you're going to spend at least 15 minutes every day studying or writing Go programs or going for a morning jog. You could draw 30 boxes on a piece of paper, one for each of the next 30 days, and check off each box as you do that day's practice.
This simple idea can be surprisingly effective, because we don't like to break a streak. If you've successfully done the habit every day for 29 days, there's a strong incentive not to break that run of success. Life has a way of coming at you, and you might well need that extra motivation at some point. Not today, not tomorrow, but soon: probably just around the time the novelty wears off.
The project is a Go package and accompanying command-line tool called habit that will help users track and establish new habits, by reporting their current streak.
Using habit
For example, if you decide you want to build the habit of jogging every day, you might tell the habit tool about it like this:
habit jog
Good luck with your new habit 'jog'! Don't forget to do it again
tomorrow.
If you want to track multiple daily habits you tell the habit tool to track your new activity, for example:
habit study
Good luck with your new habit 'study'! Don't forget to do it again
tomorrow.
As the days go by, you might record each daily practice like this:
habit jog
Nice work: you've done the habit 'jog' for 18 days in a row now.
Keep it up!
If you happen to miss a couple of days, that's all right:
habit jog
You last did the habit 'jog' 3 days ago, so you're starting a new
streak today. Good luck!
If you just want to check how you're doing, you could run:
habit
You're currently on a 1-day streak for 'jog'. Stick to it!
You're currently on a 1-day streak for 'study'. Stick to it!
or, if you keep streeks not broken:
You're currently on a 4-day streak for 'jog'. Stick to it!
You're currently on a 17-day streak for 'study'. Stick to it!
Maybe the news won't be quite so good:
You're currently on a 1-day streak for 'hike'. Stick to it!
It's been 10 days since you did 'jog'. It's ok, life happens. Get back on that horse today!
It's been 17 days since you did 'study'. It's ok, life happens. Get back on that horse today!
Installation
Storing data
habit persists data in a file storage. If you want to configure habit where to locate the file store, export the ENV variable $XDG_DATA_HOME. If the env var is not exported habit will create file store in user's $HOME directory.
Using go install
go install github.com/qba73/habit/cmd@latest
Verify installation:
habit
You are not tracking any habit yet.
Start tracking a habit:
habit jog
Good luck with your new habit 'jog'. Don't forget to do it tomorrow.
Check tracked habits:
habit
You're currently on a 1-day streak for 'jog'. Stick to it!
Building from source
Clone this repository to your local machine:
git clone git@github.com:qba73/habit.git
cd habit
Build habit binary:
go build -o habit ./cmd/main.go
Run habit:
./habit
Development
Use following make targets for developemnt and testing:
$ make
Usage:
help Show help message
dox Run tests with gotestdox
test Run tests
vet Run go vet
check Run staticcheck analyzer
cover Run unit tests and generate test coverage report
tidy Run go mod tidy
Credits
This is an educational Go project intended for students at the Bitfield Institute of Technology.