Skip to content

Commit 0296f4d

Browse files
per1234umbynos
authored andcommitted
[skip changelog] Document Arduino CLI's configuration methods (#748)
The ability to configure Arduino CLI via environment variables is only documented by a mention in the integration options article, which is not an obvious place to look for that information. Since this information didn't fit well in any of the existing pages, it makes sense to add a dedicated page, and add some documentation for the other two configuration methods as well. Although there is existing documentation for the other configuration methods elsewhere in the docs, it is missing some useful specifics, which wouldn't be appropriate to add there.
1 parent daf0878 commit 0296f4d

File tree

4 files changed

+167
-2
lines changed

4 files changed

+167
-2
lines changed

Diff for: docs/configuration.md

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
## Configuration keys
2+
3+
* `board_manager`
4+
* `additional_urls` - the URLs to any additional Board Manager package index
5+
files needed for your boards platforms.
6+
* `daemon` - options related to running Arduino CLI as a [gRPC] server.
7+
* `port` - TCP port used for gRPC client connections.
8+
* `directories` - directories used by Arduino CLI.
9+
* `data` - directory used to store Board/Library Manager index files and
10+
Board Manager platform installations.
11+
* `downloads` - directory used to stage downloaded archives during
12+
Board/Library Manager installations.
13+
* `user` - the equivalent of the Arduino IDE's
14+
["sketchbook" directory][sketchbook directory]. Library Manager
15+
installations are made to the `libraries` subdirectory of the user
16+
directory.
17+
* `logging` - configuration options for Arduino CLI's logs.
18+
* `file` - path to the file where logs will be written.
19+
* `format` - output format for the logs. Allowed values are `text` or
20+
`json`.
21+
* `level` - messages with this level and above will be logged. Valid levels
22+
are: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`.
23+
* `telemetry` - settings related to the collection of data used for continued
24+
improvement of Arduino CLI.
25+
* `addr` - TCP port used for telemetry communication.
26+
* `enabled` - controls the use of telemetry.
27+
28+
## Configuration methods
29+
30+
Arduino CLI may be configured in three ways:
31+
32+
1. Command line flags
33+
1. Environment variables
34+
1. Configuration file
35+
36+
If a configuration option is configured by multiple methods, the value set by
37+
the method highest on the above list overwrites the ones below it.
38+
39+
If a configuration option is not set, Arduino CLI uses a default value.
40+
41+
[`arduino-cli config dump`][arduino-cli config dump] displays the current
42+
configuration values.
43+
44+
### Command line flags
45+
46+
Arduino CLI's command line flags are documented in the command line help and the
47+
[Arduino CLI command reference].
48+
49+
#### Example
50+
51+
Setting an additional Board Manager URL using the
52+
[`--additional-urls`][arduino-cli global flags] command line flag:
53+
54+
```shell
55+
$ arduino-cli core update-index --additional-urls https://downloads.arduino.cc/packages/package_staging_index.json
56+
```
57+
58+
### Environment variables
59+
60+
All configuration options can be set via environment variables. The variable
61+
names start with `ARDUINO`, followed by the configuration key names, with each
62+
component separated by `_`. For example, the `ARDUINO_DIRECTORIES_USER`
63+
environment variable sets the `directories.user` configuration option.
64+
65+
On Linux or macOS, you can use the [`export` command][export command] to set
66+
environment variables. On Windows cmd, you can use the
67+
[`set` command][set command].
68+
69+
#### Example
70+
71+
Setting an additional Board Manager URL using the
72+
`ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS` environment variable:
73+
74+
```sh
75+
$ export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS=https://downloads.arduino.cc/packages/package_staging_index.json
76+
```
77+
78+
### Configuration file
79+
80+
[`arduino-cli config init`][arduino-cli config init] creates or updates a
81+
configuration file with the current configuration settings.
82+
83+
This allows saving the options set by command line flags or environment
84+
variables. For example:
85+
86+
```sh
87+
arduino-cli config init --additional-urls https://downloads.arduino.cc/packages/package_staging_index.json
88+
```
89+
90+
#### File name
91+
92+
The configuration file must be named `arduino-cli`, with the appropriate file
93+
extension for the file's format.
94+
95+
#### Supported formats
96+
97+
`arduino-cli config init` creates a YAML file, however a variety of common
98+
formats are supported:
99+
100+
* [JSON]
101+
* [TOML]
102+
* [YAML]
103+
* [Java properties file]
104+
* [HCL]
105+
* envfile
106+
* [INI]
107+
108+
#### Locations
109+
110+
Configuration files in the following locations are recognized by Arduino CLI:
111+
112+
1. Location specified by the [`--config-file`][Arduino CLI command reference]
113+
command line flag
114+
1. Current working directory
115+
1. Any parent directory of the current working directory (more immediate parents
116+
having higher precedence)
117+
1. Arduino CLI data directory (as configured by `directories.data`)
118+
119+
If multiple configuration files are present, the one highest on the above list
120+
is used. Configuration files are not combined.
121+
122+
The location of the active configuration file can be determined by running the
123+
command:
124+
125+
```sh
126+
arduino-cli config dump --verbose
127+
```
128+
129+
#### Example
130+
131+
Setting an additional Board Manager URL using a YAML format configuration file:
132+
133+
```yaml
134+
board_manager:
135+
additional_urls:
136+
- https://downloads.arduino.cc/packages/package_staging_index.json
137+
```
138+
139+
Doing the same using a TOML format file:
140+
141+
```toml
142+
[board_manager]
143+
additional_urls = [ "https://downloads.arduino.cc/packages/package_staging_index.json" ]
144+
```
145+
146+
147+
[gRPC]: https://grpc.io
148+
[sketchbook directory]: sketch-specification.md#sketchbook
149+
[arduino-cli config dump]: ../commands/arduino-cli_config_dump
150+
[Arduino CLI command reference]: ../commands/arduino-cli
151+
[arduino-cli global flags]: ../commands/arduino-cli_config/#options-inherited-from-parent-commands
152+
[export command]: https://ss64.com/bash/export.html
153+
[set command]: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1
154+
[arduino-cli config init]: ../commands/arduino-cli_config_init
155+
[JSON]: https://www.json.org
156+
[TOML]: https://github.com/toml-lang/toml
157+
[YAML]: https://en.wikipedia.org/wiki/YAML
158+
[Java properties file]: https://en.wikipedia.org/wiki/.properties
159+
[HCL]: https://github.com/hashicorp/hcl
160+
[INI]: https://en.wikipedia.org/wiki/INI_file

Diff for: docs/getting-started.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Config file written: /home/luca/.arduino15/arduino-cli.yaml
5353
```
5454

5555
If you inspect the contents of `arduino-cli.yaml`, you'll find the available
56-
options with their respective default values.
56+
options with their respective default values. For more information, see the
57+
[configuration documentation].
5758

5859
## Create a new sketch
5960

@@ -343,6 +344,7 @@ telemetry:
343344
addr: :9090
344345
```
345346
347+
[configuration documentation]: configuration.md
346348
[client_example]: https://github.com/arduino/arduino-cli/blob/master/client_example
347349
[gRPC reference]: ../rpc/commands
348350
[Prometheus]: https://prometheus.io/

Diff for: docs/integration-options.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ package index that can be used to work with experimental versions of cores:
4141
One note about the example above: passing a value through a command line flag
4242
always takes precedence over reading an environment variable, which in turn
4343
always takes precedence over reading the same value from the configuration file
44-
(if you have one).
44+
(if you have one). For more information, see the [configuration documentation].
45+
4546
Consistent with the previous paragraph, when it comes to providing output the
4647
Arduino CLI aims to be user friendly but also slightly verbose, something that
4748
doesn’t play well with robots. This is why we added an option to provide output
@@ -118,6 +119,7 @@ if you’ve got a use case that doesn’t fit one of the three pillars.
118119
[Arduino Create]: https://create.arduino.cc
119120
[continuous integration]: https://en.wikipedia.org/wiki/Continuous_integration
120121
[continuous deployment]: https://en.wikipedia.org/wiki/Continuous_deployment
122+
[configuration documentation]: configuration.md
121123
[JSON]: https://www.json.org
122124
[installation script]: installation.md#use-the-install-script
123125
[command reference]: ../commands/arduino-cli

Diff for: mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ nav:
101101
- monitor: rpc/monitor.md
102102
- settings: rpc/settings.md
103103
- debug: rpc/debug.md
104+
- configuration.md
104105
- Integration options: integration-options.md
105106
- sketch-build-process.md
106107
- sketch-specification.md

0 commit comments

Comments
 (0)