Saturday, April 4, 2020

Here We Go

For a long time, I wanted to have an application to keep my personal data in place. My requirements were next:

  • It should be lightweight and minimalistic.
  • It must present protected (hidden) and open (visible) data in the single set.
  • It should make the process of data input/edition easy, but still protects this data from an accidental unintentional change.
And here let me show you the one which I eventually built.

This application is written in Go. It is not a real Windows GUI but rather TUI and it uses an excellent Go package "rivo/tview" as the foundation. It looks and feels less like modern Windows commercial programs, but more like old fashioned PC Dos application.  Still, it does whatever expected in an efficient and straightforward way.

The terminal screen consists of two areas:

  • Top menu
  • Table with User Records

The application starts with a single argument: the path to the file with data storage. Storage is encoded and password protected. If such storage does not exist, the application will ask you to enter the new password and will create new storage.
At the start, the application puts focus on the top menu. Hitting "Enter", while button "Select" is in focus, move the focus to the table. To put the focus back on the top menu use "Esc".To navigate through the menu or the table user must use arrow keys.
Numbers of table rows and columns are unlimited but it is unlikely somebody will use more than a hundred rows or more than 3..5 columns. Each rows contains one cell (Record Name), which is always visible, and several values. Values on each row may be either all visible or all hidden.
The application supports four modes:

  • Clipboard-on-Enter. If the user hits "Enter" on the selected cell its content is copied into the clipboard.
  • Clipboard-on-Select. During navigation content of the selected cell is copied into the clipboard.
  • Visible-on-Enter. If the user hits "Enter" on the selected cell with hidden content it becomes visible. When the cell becomes unselected its content becomes hidden again.
  • Visible-on-Select. If the user selects the cell with hidden content it becomes visible. When the cell becomes unselected its content becomes hidden again.
The user may add new records (button "Add") or edit existing (button "Edit"). To edit existing record select record on the table, then by "Esc" go to the top menu and hit button "Edit". The record may be extended with one extra value. If there is a need to add several extra values repeat the process several times. The short clip below illustrates how the program works.

Source code is available . The project "readme" contains some additional details regarding its dependencies, platform support, how to build it and run the demo. If you will find the approach useful feel free to take this application as is or use it as a starting point for your own project.

Update 4/29/20. Optional and limited support of Git added to the project.

It would be not wise to keep a file with data only locally. Keeping it somewhere on remote storage provides data reliability and the ability to access it from different computers. Git repository looks like the obvious choice. It is assumed that a user will create a private repository with some Git provider and clone it locally. If "tspur" sees that data storage is located on the directory with working git tree it adds button "Git" to the top menu. That button may trigger a chain of git operations, namely: stages file with data, commits it, and pushes it to the remote.