Overview: Developing Interactive Terminal Tools

Learn how to develop an interactive Pomodoro timer application on command line.

We'll cover the following

So far, we’ve built applications that run mostly unattended. This is one of the major benefits of command-line tools: we provide the required parameters, the tool performs some actions, and it then provides us with the results. But some applications are better suited for an interactive workflow where the user provides or receives feedback continuously, like the kinds of applications in a graphical user interface (GUI).

Overview

In this chapter, we’ll develop an interactive Pomodoro timer application. The Pomodoro Technique is a time management approach that allows us to focus on tasks by defining a short time interval to concentrate on it, called a Pomodoro, followed by short and long breaks to allow us to rest and reprioritize tasks. In general, a Pomodoro interval lasts 25 minutes, while breaks are typically 5 and 15 minutes.

Instead of developing a full GUI, we’ll design and implement an interactive CLI application that runs directly on a terminal. Compared to full GUI applications, interactive CLI apps use fewer resources and often require fewer dependencies, making them more portable. Examples of this type of application include system monitoring applications, such as top or htop, and interactive disk utilities, such as ncdu.

For our Pomodoro application, we’ll implement the Repository pattern2 to abstract the data source, decoupling the business logic from the data. This way, we can implement different data stores according to our requirements. For instance, in this chapter, we’ll implement an in-memory data store for this application. We’ll expand this application by implementing another repository backed up by a SQL database.

At the end of this chapter, our Pomodoro tool will look like this.

Get hands-on with 1200+ tech skills courses.