To quickly try out the CLI, it's simple to add the Acrolinx URL and access token as command-line options. However, when you start developing with the CLI, you'll want to preconfigure these parameters instead. This is helpful for several reasons.
-
You don't have to keep sending the parameters as command-line arguments.
-
It's more secure — if you send the access token as a command-line argument, it can be retrieved from the command-line history or logging output and used for unauthorized activity.
You can preconfigure the command-line arguments in several ways:
-
Preconfigure them in environment variables
-
Save them as JSON properties in a configuration file.
At a minimum, we recommend storing the access token and the Acrolinx URL as environment variables. Many build systems have add-ons that make it even more secure to store and access sensitive information in environment variables.
All command-line arguments can be set as prefixed environment variables. The prefix is always ACROLINX_
.
The Acrolinx URL Has a Double Prefix
The command-line argument --acrolinx-url
already includes prefix acrolinx
. When you enter it as an environment variable, add a double prefix like this: ACROLINX_ACROLINX_URL
.
To set an environment variable in the Windows command line, follow this step:
-
Enter the following command:
set <VARIABLE>=<value>
For example, to set access token and the Acrolinx URL as environment variables, enter the commands like this:
set ACROLINX_ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ey...FqkOC992-g_4KUHG6YIBVA9cYiAcYs8ViH6r6Lb3U set ACROLINX_ACROLINX_URL=http://topspin.acrolinx.cloud
Set Environment Variables in the Windows User Interface
If you prefer to manage environment variables in the Windows user interface, see this helpful tutorial on "How to set the path and environment variables in Windows".
To set an environment variable in a Linux or macOS command shell, follow this step:
-
Enter the following command:
<VARIABLE>=<value>
For example, to set access token and the Acrolinx URL as environment variables, enter the commands like this:
ACROLINX_ACCESS_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ey...FqkOC992-g_4KUHG6YIBVA9cYiAcYs8ViH6r6Lb3U ACROLINX_ACROLINX_URL=http://topspin.acrolinx.cloud
Variable Persistence in Linux-based Operating Systems
In Linux-based operating systems, environment variables have different levels of persistence. If you're unfamiliar with how environment variables work in Linux-based operating systems, see this article about environment variables in Ubuntu.
Suppose that you’ve identified a combination of arguments that you would like to reuse for an automated process. You can save these arguments to a configuration file so that you only have to load the configuration file when you want to run the command again.
To save all arguments to a configuration file, follow this step:
-
In a command shell, enter the following command:
acrolinx-cli check <CHECKING_ARGUMENTS> --save-json=<FILE_NAME>
For example, if you wanted to check a set of Markdown files and save your configuration, your command might look something like this:
acrolinx-cli check --files="*.md" --guidance-profile=b8ac6a9f-cadc-44f1-b41c-e60155173096 --result-json=results/result.json --result-junit=results/xunit.xml --save-json=cli-config.json
To load all arguments from a configuration file, follow this step:
-
In a command shell, enter the following command
acrolinx-cli check --config=<FILE_NAME>
For example, to load the configuration that we saved in the previous procedure, we would enter the command like this:
acrolinx-cli check --config=cli-config.json