Command Line Interface

The Caliper SDK features a feature-rich command line interface that will serve as your main point of interaction with the product. Access it via command line script q2. By typing q2 and pressing the <Return> key, you can see all the operations, or “entrypoints”, available to you:

% q2
usage: q2 [-h] [-V]
          {add_dependency,add_nav_perms,add_new_account,add_to_nav,ardent,bounce_stack,changelog,check,create_coreflow,create_entrypoint,create_extension,create_online_user,db,test,frontend,generate_config,generate_hq_api,get_installed,get_installed_forms,insight,inspect,install,install_completion,install_form,invalidate_hq_cache,lint,remove_form,remove_from_nav,run_db_plan,run,run_sql,setup_db,setup,uninstall,update_installed_form,upgrade,vault}
          ...

positional arguments:
  {add_dependency,add_nav_perms,add_new_account,add_to_nav,ardent,bounce_stack,changelog,check,create_coreflow,create_entrypoint,create_extension,create_online_user,db,test,frontend,generate_config,generate_hq_api,get_installed,get_installed_forms,insight,inspect,install,install_completion,install_form,invalidate_hq_cache,lint,remove_form,remove_from_nav,run_db_plan,run,run_sql,setup_db,setup,uninstall,update_installed_form,upgrade,vault}
    add_dependency      Add a third party dependency to requirements
    add_nav_perms       Set nav item permissions in Q2_UserPropertyData table
    add_new_account     Creates a new account and adds HADES
    add_to_nav          Add to Online environment's Navigation Menu
    ardent              Ardent Operations
    bounce_stack        Restart the running stack (HQ, Ardent, Bridge, etc)
                        (dev only)
    changelog           Update the changelog for an extension
    check               Analyze code against Q2 deployable standards
    create_coreflow     Create an extension to handle a new core process
    create_entrypoint   Create a custom entrypoint
    create_extension    Create a new extension skeleton
    create_online_user  Creates a new Customer, User, and UserLogon in the DB
                        and set it up for immediate use
    db                  Database Operations
    test                Run unit tests on repo
    frontend            Manage frontend configuration
    generate_config     Create an empty configuration file for a given
                        extension
    generate_hq_api     Generate easy to work with hq_api code from
                        HQ_CREDENTIALS.hq_url in configuration.settings.py
    get_installed       List all extensions installed in the database
    insight             Q2 Insight API Operations
    inspect             View SDK version, HQ URL, and database parameters
    install             Install extension into Q2 database
    install_completion  Install command line completion hooks
    invalidate_hq_cache
                        Refresh the nav menu in HQ
    lint                Run linting on installed extensions
    remove_from_nav     Remove extension from Online environment's Navigation
                        Menu
    run_db_plan         Run an extension's DbPlan
    run                 Run the server
    run_sql             Run all SQL in install folders
    setup_db            Install Stored procs necessary to run the sdk
    setup               generate directories and files necessary to run sdk
    uninstall           Uninstall extension from Q2 database
    update_installed_form
                        Update the details of an installed form in the
                        database
    upgrade             Upgrade or rollback this project's q2-sdk or q2-cores,
                        tecton, or q2-smart versions
    vault               Vault Operations

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

Some of these have already been run to create your server (setup, setup_db). You’ve already used create_extension, run, install, and add_to_nav as part of the tutorial. Others you will likely use later, such as check to verify your code is valid for deployment, or upgrade to automatically download and install upgrades to the product.

You can see that each of them have a little help text associated with them. Some might also have additional parameters that can make using them more customizable. You can discover these by adding a -h at the end of the command. For instance, let’s try it with run:

$ q2 run -h
usage: q2 run [-h] [-c CONFIG_PATH] [-p PORT] [-l LOGGING_LEVEL]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_PATH        Configuration settings file path
  -p PORT               Defaults to 1980
  -l LOGGING_LEVEL, --logging-level LOGGING_LEVEL
                        DEBUG, INFO, CRITICAL, ERROR

Nice! Looks like run has several options with which to control it’s behavior. By default, it runs the server on port 1980, but throwing a -p 1981 at the end would cause it to run on 1981 instead. A very useful parameter is the -l or --logging-level flag, with which you can make your script more or less verbose.

Add some -h options to a few of the other entrypoints to familiarize yourself with the toolbox. We are always improving and adding to this CLI, which we consider a core feature of the Caliper SDK. We hope you will be impressed by its feature set, power, and ease of use.