Automation - Command Line Interface (CLI)


Overview

The CAST Imaging CLI (Command Line Interface) automation tool enables automated application analysis through the CAST Imaging API, eliminating the need for manual interaction with the UI. The Command Line Interface automation tool supports the following operations:

  • initial fast scan (process source code without running analysis)
  • deep analysis and results publication in Viewer/Dashboards (fast scans must be completed)
  • results publication in Viewer/Dashboards (deep analysis must be completed)
  • application onboarding (all operations listed above in one)
  • transaction configuration actions on fully analyzed results (not included in application onboarding operation)

Requirements

Software

  • Java Runtime Environment (JRE) or Java Development Kit (JDK): Version 8 or higher

CAST Imaging installation

Before using the Command Line Interface, ensure you have:

  1. CAST Imaging installation: A properly configured and accessible CAST Imaging v3 instance - see Global installation guide for CAST Imaging 3.x
  2. API Token: API access via the Command Line Interface tool requires authentication using a user-specific API key. Generate a key using the CAST Imaging UI in the Profile section.
  3. Source code preparation: Prepare your source code for analysis using one of these methods:

Where can I get the Command Line Interface automation tool?

The Command Line Interface automation tool is provided in an extension which you can download here: https://extend.castsoftware.com/#/extension?id=com.castsoftware.aip.console.tools&version=latestexternal link

Unzip the extension anywhere on your local disk. The Command Line Interface tool is provided as aip-console-tools-cli.jar.

What’s new?

Release Notes for the com.castsoftware.aip.console.tools extension are provided here.

Where should I run the Command Line Interface automation tool?

You can run the Command Line Interface automation tool:

  • on the machine on which the CAST Imaging imaging-services component is installed
  • on any machine that has network access to the machine where the CAST Imaging imaging-services component is installed

Available commands

Fast-Scan / FastScan

  • Creates a new application or updates an existing one
  • Performs the initial source code fast scan for a new application or refreshes source code content for an existing application
java -jar ./aip-console-tools-cli.jar Fast-Scan \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --file-path "C:\folder\some-location\sources-file.zip" \
    --verbose false \
    --exclude-patterns "tmp/, temp/, *test, tests, target/, .svn/, .git/, _Macosx/, test/"

Parameters

The following parameters are specific to the command. Other parameters are listed in Common parameters below.

ParameterAliasesRequiredDescription
--domain-name-Domain name for organizing applications (created if does not exist)
--exclude-patterns-excludeComma-separated glob patterns for file exclusion, e.g. tmp/, temp/
--exclusion-rules-Comma-separated project exclusion rules. See Exclusion rules below.
--file-path-fPath to local .zip or tar.gz file, e.g. C:\folder\some-location\sources-file.zip / /home/user/folder/sources-file.zip or path to a source folder location defined in the UI S:\some-share\ / /opt/cast/shared/common-data/<some-folder>. See Configuring source code delivery from a folder.
--node-name-Target analysis node name for application creation.

Exclusion rules

The --exclusion-rules parameter accepts the following comma-separated mnemonics (no spaces):

MnemonicDescription
EXCLUDE_EMPTY_PROJECTSExclude all empty projects
PREFER_FULL_DOT_NET_TO_BASIC_DOT_NET_WEBExclude ASP .NET web projects when a Visual C#/Basic .NET project also exists
PREFER_DOT_NET_WEB_TO_ASPExclude ASP projects when a .NET web project also exists
PREFER_FULL_JAVA_PROJECTS_TO_BASIC_JSPExclude basic JSP projects when a full JEE project exists for the same web.xml file
PREFER_MAVEN_TO_ECLIPSEExclude Eclipse Java projects when a Maven project also exists
PREFER_ECLIPSE_TO_MAVENExclude Maven Java projects when an Eclipse project also exists
EXCLUDE_EMBEDDED_ECLIPSE_PROJECTSExclude Eclipse projects inside the output folder of another Eclipse project
EXCLUDE_ECLIPSE_PROJECT_WITH_DUPLICATED_NAMEExclude Eclipse projects with duplicate names
EXCLUDE_DUPLICATE_DOT_NET_PROJECT_IN_SAME_FOLDERExclude duplicate .NET projects in the same source folder
EXCLUDE_TEST_CODEExclude test code

Example:

--exclusion-rules="EXCLUDE_EMPTY_PROJECTS,PREFER_FULL_DOT_NET_TO_BASIC_DOT_NET_WEB,PREFER_DOT_NET_WEB_TO_ASP,PREFER_FULL_JAVA_PROJECTS_TO_BASIC_JSP,PREFER_MAVEN_TO_ECLIPSE,EXCLUDE_EMBEDDED_ECLIPSE_PROJECTS,EXCLUDE_ECLIPSE_PROJECT_WITH_DUPLICATED_NAME,EXCLUDE_DUPLICATE_DOT_NET_PROJECT_IN_SAME_FOLDER,EXCLUDE_TEST_CODE"

Deep-Analyze / DeepAnalyze

  • Executes a deep analysis on an existing application with delivered source code (fast scan must be completed)
  • Publishes results in Viewer and Dashboards (can be disabled)
java -jar ./aip-console-tools-cli.jar Deep-Analyze \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --module-option "one_per_au" \
    --snapshot-name "snapshot name" \
    --process-imaging false \
    --verbose false

Parameters

The following parameters are specific to the command. Other parameters are listed in Common parameters below.

ParameterAliasesRequiredDescription
--module-option-Generates a user defined module option for either technology module or analysis unit module. Possible value is one of: full_content, one_per_au, one_per_techno. The default value is: full_content.
--process-imaging-true|false: publish results to Viewer. The default value is: true.
--publish-engineering-true|false: publish results to Dashboards. The default value is: true.
--snapshot-name-SDefines the name of the snapshot to create/re-generate. A default value is used if the parameter is omitted.

Onboard-Application / OnboardApplication

Performs the following actions in one go:

  • Fast-Scan
  • Deep-Analyze
java -jar ./aip-console-tools-cli.jar Onboard-Application \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --file-path "C:\folder\some-location\sources-file.zip" \
    --snapshot-name "SNAP name" \
    --sleep-duration 5 \
    --module-option "one_per_au"

Parameters

All parameters for the Fast-Scan and Deep-Analyze commands are available and described above. Other parameters are listed in Common parameters below.

TCC

Performs transaction configuration actions on fully analyzed results. This command requires sub commands (listed below) to specify which action to take.

Parameters

All parameters for the TCC command are listed in Common parameters below unless specified below in Sub commands.

Sub commands

The following subcommands are available (at least one must be used with TCC):

compute-function-points

Compute function points for an application.

Additional parameters:

  • --wait / --no-wait (optional): Wait for computation to complete.

Example:

java -jar ./aip-console-tools-cli.jar TCC compute-function-points \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --wait
compute-transactions

Compute transactions for an application.

Additional parameters:

  • --wait / --no-wait (optional): Wait for computation to complete

Example:

java -jar ./aip-console-tools-cli.jar TCC compute-transactions \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --wait
list-rules

List available configuration rules, optionally filtered by type.

Additional parameters:

  • --ruleType (optional): Filter rules by specific type

Examples:

# List all rules
java -jar ./aip-console-tools-cli.jar TCC list-rules \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false

# List rules by type
java -jar ./aip-console-tools-cli.jar TCC list-rules \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --ruleType "Data Functions"
check-content

View content for a specific rule.

Additional parameters:

  • --rule (required): Rule ID to inspect

Example:

java -jar ./aip-console-tools-cli.jar TCC check-content \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --rule 121
check-all-content

View content for all rules of a specific type.

Additional parameters:

  • --ruleType (optional): Rule type to inspect

Example:

java -jar ./aip-console-tools-cli.jar TCC check-all-content \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --ruleType entry
view-settings

Display function point computation settings with current and possible values.

Example:

java -jar ./aip-console-tools-cli.jar TCC view-settings \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
update-settings

Update function point computation settings.

Additional parameters:

  • --new-settings (required): Comma-separated setting=value pairs

Example:

java -jar ./aip-console-tools-cli.jar TCC update-settings \
    --server_url "CAST Imaging URL" \
    --apikey "valid key" \
    --app_name "my app" \
    --verbose false
    --new-settings "FILTER_LOOKUP_TABLES=true,DF_DEFAULT_TYPE=EIF"

Common parameters

Each command listed above has a set of common parameters as follows:

ParameterAliasesRequiredDescription
--help-hDisplay help message and exit.
--apikey / --apikey:env-API Key for authentication OR environment variable name containing the API key. Generate a key using the CAST Imaging UI in the Profile section.
--initial-retry-interval-Initial interval between retries in milliseconds (specified with --max-retries). The default value is: 1000.
--max-retries-Maximum number of retry attempts to reconnect to CAST Imaging. The default value is: 5.
--app-name-nApplication name to create or existing application name.
--server-url-sCAST Imaging URL and port, with http/https protocol (default: http://localhost:8090).
--sleep-duration-Polling interval in seconds for job status (default: 1s).
--timeout-The timeout in seconds for calls to CAST Imaging. The default value is: 90s.
--version-VPrint version information and exit.
--verbose-true|false: whether the command log should be output to the console or not, defaults to true if omitted.

Exit codes

The Command Line Interface returns specific exit codes to indicate execution status:

CodeStatusDescription
0SuccessProcessing completed successfully (also returned for --help and --version)
1Authentication ErrorAPI key missing (not provided in command or environment variable)
2Login ErrorUnable to authenticate with provided API key
3Upload ErrorError occurred during upload to CAST Imaging
4Job Creation ErrorFailed to create Add Version job or retrieve job status
5Job FailedAdd Version job terminated in unexpected state
6Missing ParameterApplication name or GUID not provided
7Application Not FoundSpecified application name or GUID doesn’t exist
8Source Folder Not FoundSource folder not found on the analysis node
9No VersionApplication has no version for the requested operation
10Version Not FoundSpecified version doesn’t exist or no version matches request criteria
1000Unexpected ErrorUnhandled error occurred (check output for details)