Datimprint fingerprint and verification software released using picocli #1877
garretwilson
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to share a new CLI program named Datimprint™ which I just released via my data processing company Jordial Corporation. The full source code is available in the Datimprint GitHub project.
The Datimprint program helps you verify that all of your data is intact by generating “data imprint” snapshots and later comparing them with current data. These data imprints contain fingerprint hashes of each file, along with other information such as file modification timestamps. The fingerprints are recursive and distinguish between a content tree (i.e. the bits) and other metadata (e.g. filename case and timestamp). Datimprint is written in Java, is multithreaded for quick checksum generation, and uses picocli for the actual command-line interface.
Datimprint creates a "data imprint" of a directory tree and stores it in datim file.
You can later check the data tree against the imprint file, to verify a backup or to check for data degradation, for example.
More instructions and explanations are available in the Datimprint overview.
I also want to discuss a little about how exactly Datimprint uses picocli. It leverages the
globalmentor-application
project, which provides aBaseCliApplication
class (which I've discussed before in the picocli tickets) which does most of the work setting up picocli, auto-detecting terminal width, turning on ANSI, setting up default conversions, etc. Basing a CLI onBaseCliApplication
allows an application to use the picocli annotations to define the application itself and not worry about all the setup/configuration boilerplate that is general for all/most applications.Another interesting (and extremely useful) class is
CliStatus
, which provides a single, updating, color-coded status line that even supports multiple threads. You have to try it out to appreciate it. (Just run thegenerate
command above on a large directory tree, for example.) Let's say some functionality is using a thread pool of eight threads (e.g. Datimprint traversing a file system to generate checksums). The status line will indicate that eight threads are working, but rather than trying to list all eight files being hashed, it will just display one of them. The way it is written, probability will cause the operations that take the longest (i.e. usually the largest files) to be be the ones displayed; the quick files won't be shown. This allows you to get an idea of the overall progress and gain insight into some of the operations taking the longest time without being lost in the weeds—which is the point of a status bar.Finally to top this off, Datimprint uses the
globalmentor-root
POM as its Maven parent POM. The Datimprint CLI subproject then defines a single Maven property,exe.main.class
, which will turn on generation of executable files. (Theexe.base.filename
is optional; it would default to the Maven artifact ID, heredatimprint-cli
, if unspecified.)Simply setting these properties results in the automatic generation of the following:
datimprint-cli-x.x.x-exe.jar
.datimprint
.datimprint.exe
, with all the metadata (company, version, etc.) set. (Note that projects using theglobalmentor-root
POM will need to change the company information and such, which they should have defined in their Maven project anyway.)datimprint-cli-x.x.x-bin.zip
anddatimprint-cli-x.x.x-bin.tar.xz
archives containing all the executable files listed above.All the tricks I had to play to pull all that off in Maven (using the presence of a Maven property as a Boolean flag; automatic generation of a Windows executable; generation of an assembly descriptor during the build and then using it, etc.) is a separate discussion altogether.
globalmentor-application
andglobalmentor-root
are open source and available on GitHub, should anyone want to use them to enhance and simplify their use of picocli.Beta Was this translation helpful? Give feedback.
All reactions