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:
- CAST Imaging installation: A properly configured and accessible CAST Imaging v3 instance - see Global installation guide for CAST Imaging 3.x
- 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.
- Source code preparation: Prepare your source code for analysis using one of these methods:
- Archive file (
.zip
ortar.gz
) - Path pointing to a Source Folder Location configured in the CAST Imaging UI
- Archive file (
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=latest
Unzip the extension anywhere on your local disk. The Command Line Interface tool is provided as aip-console-tools-cli.jar
.
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.
Parameter | Aliases | Required | Description |
---|---|---|---|
--domain-name |
- | ❌ | Domain name for organizing applications (created if does not exist) |
--exclude-patterns |
-exclude |
❌ | Comma-separated glob patterns for file exclusion, e.g. tmp/, temp/ |
--exclusion-rules |
- | ❌ | Comma-separated project exclusion rules. See Exclusion rules below. |
--file-path |
-f |
✅ | Path 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):
Mnemonic | Description |
---|---|
EXCLUDE_EMPTY_PROJECTS |
Exclude all empty projects |
PREFER_FULL_DOT_NET_TO_BASIC_DOT_NET_WEB |
Exclude ASP .NET web projects when a Visual C#/Basic .NET project also exists |
PREFER_DOT_NET_WEB_TO_ASP |
Exclude ASP projects when a .NET web project also exists |
PREFER_FULL_JAVA_PROJECTS_TO_BASIC_JSP |
Exclude basic JSP projects when a full JEE project exists for the same web.xml file |
PREFER_MAVEN_TO_ECLIPSE |
Exclude Eclipse Java projects when a Maven project also exists |
PREFER_ECLIPSE_TO_MAVEN |
Exclude Maven Java projects when an Eclipse project also exists |
EXCLUDE_EMBEDDED_ECLIPSE_PROJECTS |
Exclude Eclipse projects inside the output folder of another Eclipse project |
EXCLUDE_ECLIPSE_PROJECT_WITH_DUPLICATED_NAME |
Exclude Eclipse projects with duplicate names |
EXCLUDE_DUPLICATE_DOT_NET_PROJECT_IN_SAME_FOLDER |
Exclude duplicate .NET projects in the same source folder |
EXCLUDE_TEST_CODE |
Exclude 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.
Parameter | Aliases | Required | Description |
---|---|---|---|
--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 |
-S |
❌ | Defines 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-transactions
- list-rules
- check-content
- check-all-content
- view-settings
- update-settings
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-separatedsetting=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:
Parameter | Aliases | Required | Description |
---|---|---|---|
--help |
-h |
❌ | Display 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 |
-n |
✅ | Application name to create or existing application name. |
--server-url |
-s |
❌ | CAST 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 |
-V |
❌ | Print 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:
Code | Status | Description |
---|---|---|
0 | Success | Processing completed successfully (also returned for --help and --version ) |
1 | Authentication Error | API key missing (not provided in command or environment variable) |
2 | Login Error | Unable to authenticate with provided API key |
3 | Upload Error | Error occurred during upload to CAST Imaging |
4 | Job Creation Error | Failed to create Add Version job or retrieve job status |
5 | Job Failed | Add Version job terminated in unexpected state |
6 | Missing Parameter | Application name or GUID not provided |
7 | Application Not Found | Specified application name or GUID doesn’t exist |
8 | Source Folder Not Found | Source folder not found on the analysis node |
9 | No Version | Application has no version for the requested operation |
10 | Version Not Found | Specified version doesn’t exist or no version matches request criteria |
1000 | Unexpected Error | Unhandled error occurred (check output for details) |