Before continuing with this tutorial, you must first register in order to download the CLI installer.
Installation of the Command Line Interface (CLI)
Extract the mobilefirst-cli-installer-7.0.0.zip archive and navigate to the mobilefirst-cli-installer-7.0.0 folder.
Select the appropriate installer for your operating system and run it.
Click Install to begin the installation.
Accept the Software License Agreement.
Select the installation folder.
Accept the Pre-Installation Summary by clicking Install and then select Done when installation is complete.
Creating MobileFirst projects and native API
The CLI installer adds the installation folder to your path, so that IBM MobileFirst Platform Foundation CLI commands can be run from any directory.
Create a MobileFirst project from the CLI by using either of these commands: mobilefirst create , or mfp create
mobilefirst help – Shows how to use all the commands.
mobilefirst info - Gives the OS release, system memory, node.js version, and MobileFirst CLI version.
You can use the interactive or direct options to add native API. First navigate to the MobileFirst project directory.
Interactive Mode: mobilefirst add api
Direct Mode: mobilefirst add api --environment ios , or -e for environment
Example: (direct mode)
Creating hybrid applications
Add a hybrid application from the CLI
mobilefirst add hybrid – Creates a new hybrid application, which is generated into the /apps folder of the current project.
mobilefirst add environment – Adds an environment to your application. You can use this command in the project directory if the project contains only one app. Otherwise, select which app to add the environment to, or call the command from inside the directory of the hybrid app to which the environment should be added.
By using the interactive mode, you can select one or more environments to add.
To add environments in direct mode:
To add an application skin from the CLI, use these commands:
mobilefirst add skin – Interactive mode prompts for the platform to target and name. The current working directory must be under an existing hybrid application, and at least one environment must already be added to this app.
To add a skin in direct mode: mfp add skin [--environment|-e android|blackberry|blackberry10|iphone|ipad ]
To add optional features to a hybrid application from the CLI, use these commands:
mobilefirst add feature – Interactive mode prompts for the features to add.
To remove optional features from a hybrid application by using the CLI, use these commands:
mobilefirst remove feature – Interactive mode prompts for the features to remove.
To remove a feature direct mode: mobilefirst remove feature [fips|jsonstore|tealeaf]
Creating test servers and the build-and-deploy flow
The instance of the Liberty development server is created on the default user directory. For example: /Users/cli-user/.ibm/mobilefirst/7.0.0/server
mfp start - Starts the server. If the project is not deployed, this command runs the build-all-and-deploy flow.
mfp stop - Stops the server.
mfp run - Verbose server mode which outputs server events to a console or log.
mfp status - Gives the status of the server.
mfp build - Builds the project. When you are not in the root directory of the project, this command builds the current directory and subdirectories.
mfp deploy - Deploys anything that you built in the root directory of the project. The server is automatically created and started as needed. When you are in the adapter folder, this command deploys that adapter.
mfp bd - Builds and deploys (a combination of both commands in a single command).
mfp preview [ --noshell|-n] - Displays a preview of the current application or environment in your default browser.
mfp restart - Restarts the local test server.
mfp console - Opens the MobileFirst Console in your default web browser.
Creating and testing adapters
mfp adapter add - interactive mode
mfp adapter add --type http , or -t for type. The types of adapters that can be added are HTTP, SQL, Cast Iron, SAP Netweaver Gateway, JMS, SAP Jco, and Java.
mfp adapter call - interactive mode
To invoke and adapter in direct mode: mfp invoke [:[\"\"| --file|-f ]]
BYOE - Bring Your Own Editor: Use your favorite text editor or IDE to develop from the CLI.
Using the Export command
Exporting a project in interactive mode
By using the export command, you can create a compressed file, which contains the entire MobileFirst project, or the optimized hybrid assets to use in a native application.
mfp export - Running this command in the project root folder prompts you to enter the path and name of the compressed file to export to.
The resulting compressed file is intended to be shared with other MobileFirst developers. The compressed file contains source artifacts and everything another developer would need to build the missing artifacts.
Exporting a project in direct mode
mfp export  - If run from the root folder of the project, direct mode takes one additional argument, which is the full path to the compressed file to create.
Exporting hybrid assets in interactive mode
First run the mfp build command to make sure that the app is built.
Run the hybrid asset export within the environment folder of the existing hybrid app. Interactive mode asks whether to include the native libraries, the path, and file name of the compressed file to export to.
The native libraries are built files. Native application IDEs need to ensure that the hybrid assets can be used in a native app.
Exporting hybrid assets in direct mode
mfp export  [-i | --includeNativeLibs] - In direct mode, provide the full path to export hybrid assets. If the arguments -i or --includeNativeLibs are supplied, the native libraries are included.
Importing CLI-generated projects into MobileFirst Studio
From Eclipse, select File > Import > Existing Projects into Workspace.
The CLI can also open an existing MobileFirst Studio Eclipse project. By using the command line, navigate to a workspace that was created by Eclipse.
For more information, see the topics about the Command Line Interface in the user documentation.