Skip to content

Commit 5e04001

Browse files
committed
Add flag to set cli config file
1 parent 436276b commit 5e04001

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Diff for: handler/builder.go

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (handler *InoHandler) generateBuildEnvironment(buildPath *paths.Path) error
113113

114114
// XXX: do this from IDE or via gRPC
115115
args := []string{globalCliPath,
116+
"--config-file", globalCliConfigPath,
116117
"compile",
117118
"--fqbn", fqbn,
118119
"--only-compilation-database",

Diff for: handler/handler.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ import (
2929
)
3030

3131
var globalCliPath string
32+
var globalCliConfigPath string
3233
var globalClangdPath string
3334
var globalFormatterConf *paths.Path
3435
var enableLogging bool
3536

3637
// Setup initializes global variables.
37-
func Setup(cliPath string, clangdPath string, formatFilePath string, _enableLogging bool) {
38+
func Setup(cliPath, cliConfigPath, clangdPath, formatFilePath string, _enableLogging bool) {
3839
globalCliPath = cliPath
40+
globalCliConfigPath = cliConfigPath
3941
globalClangdPath = clangdPath
4042
if formatFilePath != "" {
4143
globalFormatterConf = paths.New(formatFilePath)
@@ -632,6 +634,7 @@ func (handler *InoHandler) initializeWorkbench(ctx context.Context, params *lsp.
632634
func extractDataFolderFromArduinoCLI() (*paths.Path, error) {
633635
// XXX: do this from IDE or via gRPC
634636
args := []string{globalCliPath,
637+
"--config-file", globalCliConfigPath,
635638
"config",
636639
"dump",
637640
"--format", "json",

Diff for: main.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
var clangdPath string
1717
var compileCommandsDir string
1818
var cliPath string
19+
var cliConfigPath string
1920
var initialFqbn string
2021
var initialBoardName string
2122
var enableLogging bool
@@ -26,6 +27,7 @@ func main() {
2627
flag.StringVar(&clangdPath, "clangd", "clangd", "Path to clangd executable")
2728
flag.StringVar(&compileCommandsDir, "compile-commands-dir", "", "Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file. If not specified, the clangd process is started without the compilation database.")
2829
flag.StringVar(&cliPath, "cli", "arduino-cli", "Path to arduino-cli executable")
30+
flag.StringVar(&cliConfigPath, "cli-config", "", "Path to arduino-cli config file")
2931
flag.StringVar(&initialFqbn, "fqbn", "arduino:avr:uno", "Fully qualified board name to use initially (can be changed via JSON-RPC)")
3032
flag.StringVar(&initialBoardName, "board-name", "", "User-friendly board name to use initially (can be changed via JSON-RPC)")
3133
flag.BoolVar(&enableLogging, "log", false, "Enable logging to files")
@@ -47,7 +49,11 @@ func main() {
4749
log.SetOutput(os.Stderr)
4850
}
4951

50-
handler.Setup(cliPath, clangdPath, formatFilePath, enableLogging)
52+
if cliConfigPath == "" {
53+
log.Fatal("Path to ArduinoCLI config file must be set.")
54+
}
55+
56+
handler.Setup(cliPath, cliConfigPath, clangdPath, formatFilePath, enableLogging)
5157
initialBoard := lsp.Board{Fqbn: initialFqbn, Name: initialBoardName}
5258

5359
stdio := streams.NewReadWriteCloser(os.Stdin, os.Stdout)

0 commit comments

Comments
 (0)