# Command Line Interface (CLI)

The Bionic Metrics CLI (Command Line Interface) allows you to perform powerful tasks on your local machine including things like managing tests and modules and running tests/suites locally.

# Prerequisites

# NodeJS and NPM

The CLI is a node package and is delivered by NPM and run via node. You must have NodeJS installed on your system.

We recommend using NVM to install NodeJS version 12 or greater.

For Windows, we recommend using WSL (Windows Subsystem for Linux).

If your setup is correct, you should be able to run the following commands from a terminal to see what versions of NodeJS and NPM are in your path.

> node --version
v13.7.054
> npm --version
6.13.6

# Chromedriver and Chrome

If you want to run tests/suites locally on your machine, you must have Chromedriver installed and in your PATH.

If not already installed, install Google Chrome

Note: Make sure the version of Chromedriver you install matches the installed version of Google Chrome. If the versions of Chromedriver and Chrome do not match, it can crash suddenly.

Once Chrome and Chromedriver are installed, verify the versions match via

> google-chrome --version
Google Chrome 79.0.3945.36
> chromedriver --version
ChromeDriver 79.0.3945.36

# Installation

The CLI is provided via an NPM package. To install you can either use npm or yarn (npm install -g yarn)

Install globally with

> npm install -g @bionicmetrics/bionic
OR
> yarn global add @bionicmetrics/bionic

Verify the installation is correct and in your PATH:

> which bionic
/home/username/.nvm/versions/node/v13.7.0/bin/bionic

> bionic --version
@bionicmetrics/bionic/1.1.1 linux-x64 node-v13.7.0

Note: to update the CLI to a newer version, use the same command

# Setup/Login

Before using the bionic CLI, you must login using the setup command:

> bionic setup
Enter Email: hello@bionicmetrics.com
Password: ***************
Setting configuration for this machine
Configuring Bionic Metrics CLI... done

# Update

Update to the latest version with the same command you used for installation

> npm install -g @bionicmetrics/bionic

# Commands

# bionic start

The start command will start a bionic agent on your local system and wait for runs from the application.

> bionic start
info: Listening...

Once you have started, you will see a new button on your dashboard:

Local Play Image

This will run the selected suite or test on your local agent instead of a cloud agent.

# bionic info

Provides information about your current setup

> bionic info

# bionic pull MODE [FILE]

Pull tests or modules down to the local file system

USAGE
  > bionic pull MODE [FILE]

ARGUMENTS
  MODE  (all|test|module) pull mode
  FILE  file path for a test or module

OPTIONS
  -d, --debug  debug mode

# bionic push MODE [FILE]

Push tests or modules to the cloud. Note this is not compatible with Git-Mode. Only use this command if you understand what you are doing.

USAGE
  > bionic push MODE [FILE]

ARGUMENTS
  MODE  (all|test|module) push mode
  FILE  file path for a test or module

OPTIONS
  -d, --debug  debug mode

# bionic run MODE GUID

Start a run for a test, suite, or dashboard

USAGE
  > bionic run MODE GUID
  > bionic run test 917e4c96-40bc-4d71-89e6-941973730c61
  > bionic run suite b6ba4870-d5e4-463e-b481-1172dbbf5ca4
  
  # Note for dashboard, you can provide the git branch name or the guid
  # Below this point are dashboard-specific
  > bionic run dashboard dev-branch
  > bionic run dashboard ea1f1616-40c8-4be1-93d0-7d2edfc5dcb9
  > bionic run dashboard dev-branch --sequential
  > bionic run dashboard dev-branch --sequential --suites "7eee75ae-d915-4ad6-a760-bed66e94c222, 0033c3fc-2c53-45c8-a5c6-510ce5ff8da"
  > bionic run dashboard dev-branch --sequential --suites "7eee75ae-d915-4ad6-a760-bed66e94c222, 0033c3fc-2c53-45c8-a5c6-510ce5ff8da"  --baseUrl "https://bionicmetrics.com" --inputJson '{"another": "input"}' 

ARGUMENTS
  MODE  (test|suite|dashboard) Run a suite, test, or dashboard
  GUID  guid of suite or test to be run. Dashboard can either be guid or git branch name.

OPTIONS
  -d, --debug            debug mode
  -l, --local            run on local agent (must have local agent running on a machine somewhere (bionic start)
  -s, --sequential       run dashboard or dashboard-suites sequentially (for dashboard runs only)
  --baseUrl=baseUrl      Override the baseUrl (for dashboard runs only)
  --inputJson=inputJson  JSON input override (for dashboard runs only)

  --suites=suites        [default: all] common-separated subset of suite guids to run for a dashboard (for dashboard
                         runs only)

# Browser Override

Learn how to override the browser used for tests in this guide: Browser Overrides

For help, run --help for any command

If you have any questions, please contact us on Slack or support@bionicmetrics.com