Skip to content

Add flag to set cli config file #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2021
Merged
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 handler/builder.go
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@ func (handler *InoHandler) generateBuildEnvironment(buildPath *paths.Path) error

// XXX: do this from IDE or via gRPC
args := []string{globalCliPath,
"--config-file", globalCliConfigPath,
"compile",
"--fqbn", fqbn,
"--only-compilation-database",
5 changes: 4 additions & 1 deletion handler/handler.go
Original file line number Diff line number Diff line change
@@ -29,13 +29,15 @@ import (
)

var globalCliPath string
var globalCliConfigPath string
var globalClangdPath string
var globalFormatterConf *paths.Path
var enableLogging bool

// Setup initializes global variables.
func Setup(cliPath string, clangdPath string, formatFilePath string, _enableLogging bool) {
func Setup(cliPath, cliConfigPath, clangdPath, formatFilePath string, _enableLogging bool) {
globalCliPath = cliPath
globalCliConfigPath = cliConfigPath
globalClangdPath = clangdPath
if formatFilePath != "" {
globalFormatterConf = paths.New(formatFilePath)
@@ -632,6 +634,7 @@ func (handler *InoHandler) initializeWorkbench(ctx context.Context, params *lsp.
func extractDataFolderFromArduinoCLI() (*paths.Path, error) {
// XXX: do this from IDE or via gRPC
args := []string{globalCliPath,
"--config-file", globalCliConfigPath,
"config",
"dump",
"--format", "json",
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (
var clangdPath string
var compileCommandsDir string
var cliPath string
var cliConfigPath string
var initialFqbn string
var initialBoardName string
var enableLogging bool
@@ -26,6 +27,7 @@ func main() {
flag.StringVar(&clangdPath, "clangd", "clangd", "Path to clangd executable")
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.")
flag.StringVar(&cliPath, "cli", "arduino-cli", "Path to arduino-cli executable")
flag.StringVar(&cliConfigPath, "cli-config", "", "Path to arduino-cli config file")
flag.StringVar(&initialFqbn, "fqbn", "arduino:avr:uno", "Fully qualified board name to use initially (can be changed via JSON-RPC)")
flag.StringVar(&initialBoardName, "board-name", "", "User-friendly board name to use initially (can be changed via JSON-RPC)")
flag.BoolVar(&enableLogging, "log", false, "Enable logging to files")
@@ -47,7 +49,11 @@ func main() {
log.SetOutput(os.Stderr)
}

handler.Setup(cliPath, clangdPath, formatFilePath, enableLogging)
if cliConfigPath == "" {
log.Fatal("Path to ArduinoCLI config file must be set.")
}

handler.Setup(cliPath, cliConfigPath, clangdPath, formatFilePath, enableLogging)
initialBoard := lsp.Board{Fqbn: initialFqbn, Name: initialBoardName}

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