Skip to content

#1447 - back-end usage scenario #1536

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/arduino/arduino-cli/metrics"
srv_commands "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
srv_debug "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/debug/v1"
srv_files "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1"
srv_monitor "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/monitor/v1"
srv_settings "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1"
"github.com/segmentio/stats/v4"
Expand Down Expand Up @@ -98,6 +99,9 @@ func runDaemonCommand(cmd *cobra.Command, args []string) {
// Register the debug session service
srv_debug.RegisterDebugServiceServer(s, &daemon.DebugService{})

// Register the files service
srv_files.RegisterFilesServiceServer(s, &daemon.FilesService{})

if !daemonize {
// When parent process ends terminate also the daemon
go func() {
Expand Down
41 changes: 41 additions & 0 deletions commands/daemon/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file is part of arduino-cli.
//
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to [email protected].

package daemon

import (
"context"
"os"

rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/files/v1"
)

// FilesService implements the `Files` service
type FilesService struct {
rpc.UnimplementedFilesServiceServer
}

// LoadFile returns a requested file content or an error.
func (s *FilesService) LoadFile(ctx context.Context, req *rpc.LoadFileRequest) (*rpc.LoadFileResponse, error) {
content, err := os.ReadFile(req.Path)
if err == nil {
return &rpc.LoadFileResponse{
Content: content,
Type: rpc.ContentType_CONTENT_TYPE_RAW_UNSPECIFIED,
}, nil
}

return nil, err
}
317 changes: 317 additions & 0 deletions rpc/cc/arduino/cli/files/v1/files.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading