Building Block View
Level 2: CLI (Whitebox)
Purpose / Responsibility
The command line interface (CLI) is based on the Kotlin CLI parser kotlinx-cli, aiming to bring watermarking functionalities into the terminal. It is able to embed and extract watermarks from Strings directly in the terminal and files. The CLI tool is easy to extend with custom commands and arguments. Under the hood, it uses the Innamark watermark library with the Java build target as Gradle dependency.
Expansion
To expand upon the CLI tool's current functionality you will have to:
- Create a new
kotlinx.cli.Subcommandclass for argument parsing within theclifunction. - Create a new function for the new actions that can be called by the subcommand class's
executeoverride function. - For top-Level commands (like
Add,Text,Remove):- Add the new subcommand class to the
parser.subcommandslist within theclifunction.
- Add the new subcommand class to the
- For lower-Level commands (like
TextAdd,TextList,TextRemove):- Register the new subcommand to the parent subcommand class using the
initblock andthis. subcommands.
- Register the new subcommand to the parent subcommand class using the
Contained Blackboxes
| Building Block | Description |
|---|---|
| Main | The Main file contains the full logic of the CLI tool, like parsing CLI arguments and executing them. |
| Watermarker Library | A Kotlin multiplatform library, offering watermark embedding and extraction functionalities, integrated as external Gradle dependency with the JVM build target. |
| kotlinx-cli | A generic command-line parser for Kotlin, integrated as external Gradle dependency. |