[en] 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.
-
[en] You don't have to keep sending the parameters as command-line arguments.
-
[en] 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.
[en] You can preconfigure the command-line arguments in several ways:
-
[en] Preconfigure them in environment variables
-
[en] Save them as JSON properties in a configuration file.
[en] 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.
[en] All command-line arguments can be set as prefixed environment variables. The prefix is always ACROLINX_
.
[en] The Acrolinx URL Has a Double Prefix
[en] 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
.
[en] To set an environment variable in the Windows command line, follow this step:
-
[en] Enter the following command:
set <VARIABLE>=<value>
[en] 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
[en] Set Environment Variables in the Windows User Interface
[en] 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".
[en] To set an environment variable in a Linux or macOS command shell, follow this step:
-
[en] Enter the following command:
<VARIABLE>=<value>
[en] 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
[en] Variable Persistence in Linux-based Operating Systems
[en] 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.
[en] 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.
[en] To save all arguments to a configuration file, follow this step:
-
[en] In a command shell, enter the following command:
acrolinx-cli check <CHECKING_ARGUMENTS> --save-json=<FILE_NAME>
[en] 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
[en] To load all arguments from a configuration file, follow this step:
-
[en] In a command shell, enter the following command
acrolinx-cli check --config=<FILE_NAME>
[en] 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