Unverified Commit bfb5f3f1 authored by MatteoPologruto's avatar MatteoPologruto Committed by GitHub

[Skip-changelog] Improve documentation regarding `ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS` (#2136)

* Print error message if `board_manager.additional_urls` contains comma separated urls

* Improve documentation regarding the usage of environment variables
parent 042f76af
......@@ -76,6 +76,8 @@ variable sets the `directories.user` configuration option.
On Linux or macOS, you can use the [`export` command][export command] to set environment variables. On Windows cmd, you
can use the [`set` command][set command].
`ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS` environment variables can be a list of space-separated URLs.
#### Example
Setting an additional Boards Manager URL using the `ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS` environment variable:
......@@ -84,6 +86,12 @@ Setting an additional Boards Manager URL using the `ARDUINO_BOARD_MANAGER_ADDITI
$ export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS=https://downloads.arduino.cc/packages/package_staging_index.json
```
Setting multiple additional Boards Manager URLs using the `ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS` environment variable:
```sh
$ export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS="https://downloads.arduino.cc/packages/package_staging_index.json https://downloads.arduino.cc/packages/package_mbed_index.json"
```
### Configuration file
[`arduino-cli config init`][arduino-cli config init] creates or updates a configuration file with the current
......
......@@ -17,6 +17,7 @@ package config
import (
"os"
"strings"
"github.com/arduino/arduino-cli/configuration"
"github.com/arduino/arduino-cli/internal/cli/arguments"
......@@ -97,6 +98,13 @@ func runInitCommand(cmd *cobra.Command, args []string) {
configuration.SetDefaults(newSettings)
configuration.BindFlags(cmd, newSettings)
for _, url := range newSettings.GetStringSlice("board_manager.additional_urls") {
if strings.Contains(url, ",") {
feedback.Fatal(tr("Urls cannot contain commas. Separate multiple urls exported as env var with a space:\n%s", url),
feedback.ErrGeneric)
}
}
if err := newSettings.WriteConfigAs(configFileAbsPath.String()); err != nil {
feedback.Fatal(tr("Cannot create config file: %v", err), feedback.ErrGeneric)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment