Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Allow setting additional CLI arguments #1654

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
| `arduino.useArduinoCli` | Whether to use the Arduino CLI (`true`) or the legacy Arduino IDE (`false`) -- defaults to `false`. If using `true`, either leave the `arduino.path` and `arduino.commandPath` values unset to use the bundled version of Arduino CLI, or point them at a custom version of Arduino CLI. Note that a future version of the extension will change this default to `true` and remove support for legacy Arduino IDE. |
| `arduino.path` | Path to the Arduino installation. You can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/<username>/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your legacy Arduino IDE installation path. To use the Arduino CLI, use the path that contains the `arduino-cli` executable (e.g. `/usr/local/bin`), or leave it unset to use the bundled version of Arduino CLI. |
| `arduino.commandPath` | Path to an executable (or script) relative to `arduino.path`. The default value is `arduino_debug.exe` for Windows, `Contents/MacOS/Arduino` for Mac and `arduino` for Linux, You also can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac and `bin/run-arduino.sh` for Linux. To use the bundled version of Arduino CLI, leave this option unset. To use a custom version of Arduino CLI, use `arduino-cli`. |
| `arduino.additionalCliArguments` | Additional arguments to append at the tail of the build command. |
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages as a string array. The default value is empty. |
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
| `arduino.clearOutputOnBuild` | Clear the output logs before uploading or verifying. Default value is `false`. |
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
"default": "",
"description": "Path to a script relative to 'arduino.path', you can use a custom launch script to run Arduino by modifying this setting. Example: 'run-arduino.bat' for Windows, 'Contents/MacOS/run-arduino.sh' for Mac, 'bin/run-arduino.sh' for Linux. (Requires a restart after change)"
},
"arduino.additionalCliArguments": {
"type": "array",
"items": {
"type": "string"
},
"description": "Additional arguments to append at the tail of the build command."
},
"arduino.additionalUrls": {
"type": "array",
"items": {
Expand Down
4 changes: 4 additions & 0 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,10 @@ export class ArduinoApp {
UsbDetector.getInstance().pauseListening();
}

for (const additionalArg in VscodeSettings.getInstance().additionalCliArguments) {
args.push(additionalArg);
}

// Push sketch as last argument
args.push(path.join(ArduinoWorkspace.rootPath, dc.sketch));

Expand Down
6 changes: 6 additions & 0 deletions src/arduino/vscodeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const configKeys = {
DISABLE_INTELLISENSE_AUTO_GEN: "arduino.disableIntelliSenseAutoGen",
ANALYZE_ON_OPEN: "arduino.analyzeOnOpen",
ANALYZE_ON_SETTING_CHANGE: "arduino.analyzeOnSettingChange",
ADDITIONAL_CLI_ARGUMENTS: "arduino.additionalCliArguments",
};

export interface IVscodeSettings {
arduinoPath: string;
commandPath: string;
additionalCliArguments: string[];
additionalUrls: string[];
logLevel: string;
clearOutputOnBuild: boolean;
Expand Down Expand Up @@ -71,6 +73,10 @@ export class VscodeSettings implements IVscodeSettings {
return this.setConfigValue(configKeys.ARDUINO_COMMAND_PATH, value, true);
}

public get additionalCliArguments(): string[] {
return this.getConfigValue<string[]>(configKeys.ADDITIONAL_CLI_ARGUMENTS);
}

public get additionalUrls(): string[] {
const value = this.getConfigValue<string | string[]>(configKeys.ADDITIONAL_URLS);

Expand Down