Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unexpected behavior of --config-file global command line option #753

Copy link
Copy link
Open
@per1234

Description

@per1234
Issue body actions

Bug Report

Current behavior

The --config-file global command line option currently only defines the directory containing the configuration file. It does not allow configuring the specific configuration file within that directory.

arduino-cli expects the path specified via --config-file to contain a file named with the prefix arduino-cli followed by a file extension associated with one of the supported formats.

$ ./arduino-cli config dump --verbose --config-file ./config
INFO[0000] Using config file: /home/per/ArduinoIDE/arduino-cli_nightly/config/arduino-cli.json

Even if you specify a filename, it will be ignored:

$ ./arduino-cli config dump --verbose --config-file ./config/foo.json
INFO[0000] Using config file: /home/per/ArduinoIDE/arduino-cli_nightly/config/arduino-cli.json

Unless the file doesn't exist:

$ ./arduino-cli config dump --verbose --config-file ./config/nonexistent.json
INFO[0000] Config file not found, using default values  

If the configuration directory contains multiple configuration files, there is a specific order of precedence that determines which one is used, regardless of the filename provided to the --config-file option:

$ ./arduino-cli config dump --verbose --config-file ./config/arduino-cli.toml
INFO[0000] Using config file: /home/per/ArduinoIDE/arduino-cli_nightly/config/arduino-cli.json 

(note that I specified the .toml file, but the .json file was used instead)
The order of precedence:

  • JSON
  • TOML
  • YAML
  • Java properties file
  • HCL
  • envfile
  • INI

Expected behavior

The --config-file option's documentation seems somewhat misleading to me:

--config-file string        The custom config file (if not specified the default will be used).

From reading that, I would expect to be able to specify any arbitrary filename (with the appropriate file extension for the file's format).

I don't have a problem with the current behavior of arduino-cli regarding custom configuration file locations, it's just not the behavior I expect from the option name and command line help. I don't think requiring a specific filename (arduino-cli) is onerous, and I don't think it likely the user will ever have configuration files of multiple formats in the configuration directory (I only discovered this because I was verifying support for all the formats). So a simple solution for this would be keep the current behavior, but change the option name to something like --config-dir (hopefully keeping --config-file as an undocumented alias for backwards compatibility), and update the command line help accordingly.

Environment

  • CLI version (output of arduino-cli version): 0.11.0-rc1 Commit: 5373961
  • OS and platform: Ubuntu 20.04, Windows 10

Metadata

Metadata

Assignees

Labels

topic: CLIRelated to the command line interfaceRelated to the command line interfacetype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.