CLI

The Product Kernel provides a library that executes a controller in Command Line mode. Each product can create its own executable and invoke this library.

Overview

The "Cli" class acts as a wrapper class for an IController instance. It is used to execute its functionality while at the same time printing messages to the console (i.e standard output and standard error streams) that describe the process. This might be used to provide a minimalistic user experience besides the more complex Electron GUI bundles.

How to use

  1. Create an entry point for your executable (i.e a new console application targeting either .net framework or .net core). All generic infrastructure functionality currently compiles to .net standard 2.0.

  2. Install the Mobilize.Common.CLI package, which shares the same versioning as the Mobilize.Common.Controller package.

  3. In the Main() method of your application, create an instance of a Controller object as you normally would in the creation of a UI bundle. By transitivity, this also involves creating an instance of your Code Processor object, as this is also passed to the controller.

  4. Add command-line arguments definition and processing for your console application. No restrictions are imposed in terms of what the parameters should be or how should be named.

  5. Call the CLI class methods from your main program as needed. Some parameters (detailed below) must be provided. Is up to the CLI bundle implementation if these parameters are introduced as command-line arguments or are obtained by other means (e.g constants, configuration files, etc).

When creating the Controller, make sure to pass a log configuration object which indicates the minimum log level to use with the console. Otherwise, no logging output will be printed to the console.

For an example that can be used as a reference please check the Dummy Product Bundle CLI bundle.

CLI class API

  • Constructor: Receives an instance of an IController object.

  • GetLicenseAndShowLicenseInformation: This method retrieves and prints to the console all the information related to a license assuming there is one installed. If there is no license installed, then no information will be shown.

  • InstallOrActivateLicense: This method downloads and activates the license into the user's machine by using the provided key. The download step might be skipped if the license is already installed. In case some problem occurs an error message is shown on the console.

  • Convert: This method performs parameters validation and instructs the controller to set up and execute the code processor.

Last updated