Unverified Commit ec376ded authored by Anton Smirnov's avatar Anton Smirnov Committed by GitHub

Add gRPC function to create new Sketch (#1498)

* #1456 - Add "new sketch" in gRPC .proto, regenerate .pg.go. Use "user" dir for sketches created via gRPC

* #1456 - Avoid using hardcoded extension (address comment).

* #1456 - Add optional dir field in the request, use it.

* #1456 - Use go-paths-helper

* Use gRPC function from CLI to create new sketch
Co-authored-by: default avatarSilvano Cerza <silvanocerza@gmail.com>
parent 1bd9945c
......@@ -16,13 +16,16 @@
package sketch
import (
"io/ioutil"
"context"
"os"
"path/filepath"
"strings"
"github.com/arduino/arduino-cli/arduino/globals"
"github.com/arduino/arduino-cli/cli/errorcodes"
"github.com/arduino/arduino-cli/cli/feedback"
sk "github.com/arduino/arduino-cli/commands/sketch"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
"github.com/spf13/cobra"
)
......@@ -38,32 +41,24 @@ func initNewCommand() *cobra.Command {
return newCommand
}
var emptySketch = []byte(`
void setup() {
}
void loop() {
}
`)
func runNewCommand(cmd *cobra.Command, args []string) {
// Trim to avoid issues if user creates a sketch adding the .ino extesion to the name
trimmedSketchName := strings.TrimSuffix(args[0], ".ino")
sketchDir, err := filepath.Abs(trimmedSketchName)
sketchName := args[0]
trimmedSketchName := strings.TrimSuffix(sketchName, globals.MainFileValidExtension)
sketchDirPath, err := paths.New(trimmedSketchName).Abs()
if err != nil {
feedback.Errorf(tr("Error creating sketch: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
if err := os.MkdirAll(sketchDir, os.FileMode(0755)); err != nil {
feedback.Errorf(tr("Could not create sketch directory: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
sketchName := filepath.Base(sketchDir)
sketchFile := filepath.Join(sketchDir, sketchName+".ino")
if err := ioutil.WriteFile(sketchFile, emptySketch, os.FileMode(0644)); err != nil {
_, err = sk.NewSketch(context.Background(), &rpc.NewSketchRequest{
Instance: nil,
SketchName: sketchDirPath.Base(),
SketchDir: sketchDirPath.Parent().String(),
})
if err != nil {
feedback.Errorf(tr("Error creating sketch: %v"), err)
os.Exit(errorcodes.ErrGeneric)
}
feedback.Print(tr("Sketch created in: %s", sketchDir))
feedback.Print(tr("Sketch created in: %s", sketchDirPath))
}
......@@ -243,6 +243,12 @@ func (s *ArduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionReq
return &rpc.VersionResponse{Version: s.VersionString}, nil
}
// NewSketch FIXMEDOC
func (s *ArduinoCoreServerImpl) NewSketch(ctx context.Context, req *rpc.NewSketchRequest) (*rpc.NewSketchResponse, error) {
resp, err := sketch.NewSketch(ctx, req)
return resp, convertErrorToRPCStatus(err)
}
// LoadSketch FIXMEDOC
func (s *ArduinoCoreServerImpl) LoadSketch(ctx context.Context, req *rpc.LoadSketchRequest) (*rpc.LoadSketchResponse, error) {
resp, err := commands.LoadSketch(ctx, req)
......
......@@ -368,6 +368,19 @@ func (e *MissingSketchPathError) ToRPCStatus() *status.Status {
return status.New(codes.InvalidArgument, e.Error())
}
// CantCreateSketchError is returned when the sketch cannot be created
type CantCreateSketchError struct {
Cause error
}
func (e *CantCreateSketchError) Error() string {
return composeErrorMsg(tr("Can't create sketch"), e.Cause)
}
func (e *CantCreateSketchError) Unwrap() error {
return e.Cause
}
// CantOpenSketchError is returned when the sketch is not found or cannot be opened
type CantOpenSketchError struct {
Cause error
......
// 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 license@arduino.cc.
package sketch
import (
"context"
"github.com/arduino/arduino-cli/arduino/globals"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/configuration"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
)
var emptySketch = []byte(`
void setup() {
}
void loop() {
}
`)
// NewSketch creates a new sketch via gRPC
func NewSketch(ctx context.Context, req *rpc.NewSketchRequest) (*rpc.NewSketchResponse, error) {
var sketchesDir string
if len(req.SketchDir) > 0 {
sketchesDir = req.SketchDir
} else {
sketchesDir = configuration.Settings.GetString("directories.User")
}
sketchDirPath := paths.New(sketchesDir).Join(req.SketchName)
if err := sketchDirPath.MkdirAll(); err != nil {
return nil, &commands.CantCreateSketchError{Cause: err}
}
sketchName := sketchDirPath.Base()
sketchMainFilePath := sketchDirPath.Join(sketchName + globals.MainFileValidExtension)
if err := sketchMainFilePath.WriteFile(emptySketch); err != nil {
return nil, &commands.CantCreateSketchError{Cause: err}
}
return &rpc.NewSketchResponse{MainFile: sketchMainFilePath.String()}, nil
}
......@@ -70,7 +70,7 @@ msgstr "%s pattern is missing"
msgid "%s uninstalled"
msgstr "%s uninstalled"
#: commands/errors.go:658
#: commands/errors.go:671
msgid "'%s' has an invalid signature"
msgstr "'%s' has an invalid signature"
......@@ -247,6 +247,10 @@ msgstr "Builds of 'core.a' are saved into this path to be cached and reused."
msgid "Can't create data directory %s"
msgstr "Can't create data directory %s"
#: commands/errors.go:377
msgid "Can't create sketch"
msgstr "Can't create sketch"
#: commands/lib/download.go:60
#: commands/lib/download.go:63
#: commands/lib/download.go:65
......@@ -260,7 +264,7 @@ msgstr "Can't download library"
msgid "Can't find dependencies for platform %s"
msgstr "Can't find dependencies for platform %s"
#: commands/errors.go:377
#: commands/errors.go:390
msgid "Can't open sketch"
msgstr "Can't open sketch"
......@@ -294,11 +298,11 @@ msgstr "Cannot create config file directory: %v"
msgid "Cannot create config file: %v"
msgstr "Cannot create config file: %v"
#: commands/errors.go:621
#: commands/errors.go:634
msgid "Cannot create temp dir"
msgstr "Cannot create temp dir"
#: commands/errors.go:639
#: commands/errors.go:652
msgid "Cannot create temp file"
msgstr "Cannot create temp file"
......@@ -448,10 +452,6 @@ msgstr "Could not connect via HTTP"
msgid "Could not create index directory"
msgstr "Could not create index directory"
#: cli/sketch/new.go:58
msgid "Could not create sketch directory: %v"
msgstr "Could not create sketch directory: %v"
#: legacy/builder/phases/core_builder.go:48
msgid "Couldn't deeply cache core build: {0}"
msgstr "Couldn't deeply cache core build: {0}"
......@@ -465,8 +465,8 @@ msgstr "Couldn't determine program size"
msgid "Couldn't get current working directory: %v"
msgstr "Couldn't get current working directory: %v"
#: cli/sketch/new.go:32
#: cli/sketch/new.go:33
#: cli/sketch/new.go:35
#: cli/sketch/new.go:36
msgid "Create a new Sketch"
msgstr "Create a new Sketch"
......@@ -655,8 +655,8 @@ msgstr "Error creating output dir"
msgid "Error creating sketch archive"
msgstr "Error creating sketch archive"
#: cli/sketch/new.go:54
#: cli/sketch/new.go:64
#: cli/sketch/new.go:50
#: cli/sketch/new.go:59
msgid "Error creating sketch: %v"
msgstr "Error creating sketch: %v"
......@@ -1344,7 +1344,7 @@ msgstr "Library '%s' not found"
msgid "Library can't use both '%[1]s' and '%[2]s' folders. Double check {0}"
msgstr "Library can't use both '%[1]s' and '%[2]s' folders. Double check {0}"
#: commands/errors.go:414
#: commands/errors.go:427
msgid "Library install failed"
msgstr "Library install failed"
......@@ -1741,7 +1741,7 @@ msgstr "Port"
msgid "Port closed:"
msgstr "Port closed:"
#: commands/errors.go:508
#: commands/errors.go:521
msgid "Port monitor error"
msgstr "Port monitor error"
......@@ -1978,7 +1978,7 @@ msgstr "Size (bytes):"
msgid "Sketch cannot be located in build path. Please specify a different build path"
msgstr "Sketch cannot be located in build path. Please specify a different build path"
#: cli/sketch/new.go:68
#: cli/sketch/new.go:63
msgid "Sketch created in: %s"
msgstr "Sketch created in: %s"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,6 +64,9 @@ service ArduinoCoreService {
// Get the version of Arduino CLI in use.
rpc Version(VersionRequest) returns (VersionResponse) {}
// Create a new Sketch
rpc NewSketch(NewSketchRequest) returns (NewSketchResponse) {}
// Returns all files composing a Sketch
rpc LoadSketch(LoadSketchRequest) returns (LoadSketchResponse) {}
......@@ -280,6 +283,23 @@ message VersionResponse {
string version = 1;
}
message NewSketchRequest {
// Arduino Core Service instance from the Init response.
Instance instance = 1;
// New sketch name
string sketch_name = 2;
// Optional: create a Sketch in this directory
// (used as "Sketchbook" directory).
// Default Sketchbook directory "directories.User" is used if sketch_dir is
// empty.
string sketch_dir = 3;
}
message NewSketchResponse {
// Absolute path to a main sketch file
string main_file = 1;
}
message LoadSketchRequest {
// Arduino Core Service instance from the Init response.
Instance instance = 1;
......
......@@ -11,6 +11,7 @@ import (
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// ArduinoCoreServiceClient is the client API for ArduinoCoreService service.
......@@ -36,6 +37,8 @@ type ArduinoCoreServiceClient interface {
Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (ArduinoCoreService_UpgradeClient, error)
// Get the version of Arduino CLI in use.
Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error)
// Create a new Sketch
NewSketch(ctx context.Context, in *NewSketchRequest, opts ...grpc.CallOption) (*NewSketchResponse, error)
// Returns all files composing a Sketch
LoadSketch(ctx context.Context, in *LoadSketchRequest, opts ...grpc.CallOption) (*LoadSketchResponse, error)
// Creates a zip file containing all files of specified Sketch
......@@ -124,7 +127,7 @@ func (c *arduinoCoreServiceClient) Create(ctx context.Context, in *CreateRequest
}
func (c *arduinoCoreServiceClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (ArduinoCoreService_InitClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[0], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Init", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[0], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Init", opts...)
if err != nil {
return nil, err
}
......@@ -165,7 +168,7 @@ func (c *arduinoCoreServiceClient) Destroy(ctx context.Context, in *DestroyReque
}
func (c *arduinoCoreServiceClient) UpdateIndex(ctx context.Context, in *UpdateIndexRequest, opts ...grpc.CallOption) (ArduinoCoreService_UpdateIndexClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[1], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateIndex", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[1], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateIndex", opts...)
if err != nil {
return nil, err
}
......@@ -197,7 +200,7 @@ func (x *arduinoCoreServiceUpdateIndexClient) Recv() (*UpdateIndexResponse, erro
}
func (c *arduinoCoreServiceClient) UpdateLibrariesIndex(ctx context.Context, in *UpdateLibrariesIndexRequest, opts ...grpc.CallOption) (ArduinoCoreService_UpdateLibrariesIndexClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[2], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateLibrariesIndex", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[2], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateLibrariesIndex", opts...)
if err != nil {
return nil, err
}
......@@ -229,7 +232,7 @@ func (x *arduinoCoreServiceUpdateLibrariesIndexClient) Recv() (*UpdateLibrariesI
}
func (c *arduinoCoreServiceClient) UpdateCoreLibrariesIndex(ctx context.Context, in *UpdateCoreLibrariesIndexRequest, opts ...grpc.CallOption) (ArduinoCoreService_UpdateCoreLibrariesIndexClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[3], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateCoreLibrariesIndex", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[3], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UpdateCoreLibrariesIndex", opts...)
if err != nil {
return nil, err
}
......@@ -270,7 +273,7 @@ func (c *arduinoCoreServiceClient) Outdated(ctx context.Context, in *OutdatedReq
}
func (c *arduinoCoreServiceClient) Upgrade(ctx context.Context, in *UpgradeRequest, opts ...grpc.CallOption) (ArduinoCoreService_UpgradeClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[4], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Upgrade", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[4], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Upgrade", opts...)
if err != nil {
return nil, err
}
......@@ -310,6 +313,15 @@ func (c *arduinoCoreServiceClient) Version(ctx context.Context, in *VersionReque
return out, nil
}
func (c *arduinoCoreServiceClient) NewSketch(ctx context.Context, in *NewSketchRequest, opts ...grpc.CallOption) (*NewSketchResponse, error) {
out := new(NewSketchResponse)
err := c.cc.Invoke(ctx, "/cc.arduino.cli.commands.v1.ArduinoCoreService/NewSketch", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *arduinoCoreServiceClient) LoadSketch(ctx context.Context, in *LoadSketchRequest, opts ...grpc.CallOption) (*LoadSketchResponse, error) {
out := new(LoadSketchResponse)
err := c.cc.Invoke(ctx, "/cc.arduino.cli.commands.v1.ArduinoCoreService/LoadSketch", in, out, opts...)
......@@ -338,7 +350,7 @@ func (c *arduinoCoreServiceClient) BoardDetails(ctx context.Context, in *BoardDe
}
func (c *arduinoCoreServiceClient) BoardAttach(ctx context.Context, in *BoardAttachRequest, opts ...grpc.CallOption) (ArduinoCoreService_BoardAttachClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[5], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BoardAttach", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[5], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BoardAttach", opts...)
if err != nil {
return nil, err
}
......@@ -397,7 +409,7 @@ func (c *arduinoCoreServiceClient) BoardSearch(ctx context.Context, in *BoardSea
}
func (c *arduinoCoreServiceClient) BoardListWatch(ctx context.Context, opts ...grpc.CallOption) (ArduinoCoreService_BoardListWatchClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[6], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BoardListWatch", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[6], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BoardListWatch", opts...)
if err != nil {
return nil, err
}
......@@ -428,7 +440,7 @@ func (x *arduinoCoreServiceBoardListWatchClient) Recv() (*BoardListWatchResponse
}
func (c *arduinoCoreServiceClient) Compile(ctx context.Context, in *CompileRequest, opts ...grpc.CallOption) (ArduinoCoreService_CompileClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[7], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Compile", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[7], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Compile", opts...)
if err != nil {
return nil, err
}
......@@ -460,7 +472,7 @@ func (x *arduinoCoreServiceCompileClient) Recv() (*CompileResponse, error) {
}
func (c *arduinoCoreServiceClient) PlatformInstall(ctx context.Context, in *PlatformInstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_PlatformInstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[8], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformInstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[8], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformInstall", opts...)
if err != nil {
return nil, err
}
......@@ -492,7 +504,7 @@ func (x *arduinoCoreServicePlatformInstallClient) Recv() (*PlatformInstallRespon
}
func (c *arduinoCoreServiceClient) PlatformDownload(ctx context.Context, in *PlatformDownloadRequest, opts ...grpc.CallOption) (ArduinoCoreService_PlatformDownloadClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[9], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformDownload", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[9], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformDownload", opts...)
if err != nil {
return nil, err
}
......@@ -524,7 +536,7 @@ func (x *arduinoCoreServicePlatformDownloadClient) Recv() (*PlatformDownloadResp
}
func (c *arduinoCoreServiceClient) PlatformUninstall(ctx context.Context, in *PlatformUninstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_PlatformUninstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[10], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformUninstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[10], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformUninstall", opts...)
if err != nil {
return nil, err
}
......@@ -556,7 +568,7 @@ func (x *arduinoCoreServicePlatformUninstallClient) Recv() (*PlatformUninstallRe
}
func (c *arduinoCoreServiceClient) PlatformUpgrade(ctx context.Context, in *PlatformUpgradeRequest, opts ...grpc.CallOption) (ArduinoCoreService_PlatformUpgradeClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[11], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformUpgrade", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[11], "/cc.arduino.cli.commands.v1.ArduinoCoreService/PlatformUpgrade", opts...)
if err != nil {
return nil, err
}
......@@ -588,7 +600,7 @@ func (x *arduinoCoreServicePlatformUpgradeClient) Recv() (*PlatformUpgradeRespon
}
func (c *arduinoCoreServiceClient) Upload(ctx context.Context, in *UploadRequest, opts ...grpc.CallOption) (ArduinoCoreService_UploadClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[12], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Upload", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[12], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Upload", opts...)
if err != nil {
return nil, err
}
......@@ -620,7 +632,7 @@ func (x *arduinoCoreServiceUploadClient) Recv() (*UploadResponse, error) {
}
func (c *arduinoCoreServiceClient) UploadUsingProgrammer(ctx context.Context, in *UploadUsingProgrammerRequest, opts ...grpc.CallOption) (ArduinoCoreService_UploadUsingProgrammerClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[13], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UploadUsingProgrammer", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[13], "/cc.arduino.cli.commands.v1.ArduinoCoreService/UploadUsingProgrammer", opts...)
if err != nil {
return nil, err
}
......@@ -670,7 +682,7 @@ func (c *arduinoCoreServiceClient) ListProgrammersAvailableForUpload(ctx context
}
func (c *arduinoCoreServiceClient) BurnBootloader(ctx context.Context, in *BurnBootloaderRequest, opts ...grpc.CallOption) (ArduinoCoreService_BurnBootloaderClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[14], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BurnBootloader", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[14], "/cc.arduino.cli.commands.v1.ArduinoCoreService/BurnBootloader", opts...)
if err != nil {
return nil, err
}
......@@ -720,7 +732,7 @@ func (c *arduinoCoreServiceClient) PlatformList(ctx context.Context, in *Platfor
}
func (c *arduinoCoreServiceClient) LibraryDownload(ctx context.Context, in *LibraryDownloadRequest, opts ...grpc.CallOption) (ArduinoCoreService_LibraryDownloadClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[15], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryDownload", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[15], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryDownload", opts...)
if err != nil {
return nil, err
}
......@@ -752,7 +764,7 @@ func (x *arduinoCoreServiceLibraryDownloadClient) Recv() (*LibraryDownloadRespon
}
func (c *arduinoCoreServiceClient) LibraryInstall(ctx context.Context, in *LibraryInstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_LibraryInstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[16], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryInstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[16], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryInstall", opts...)
if err != nil {
return nil, err
}
......@@ -784,7 +796,7 @@ func (x *arduinoCoreServiceLibraryInstallClient) Recv() (*LibraryInstallResponse
}
func (c *arduinoCoreServiceClient) ZipLibraryInstall(ctx context.Context, in *ZipLibraryInstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_ZipLibraryInstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[17], "/cc.arduino.cli.commands.v1.ArduinoCoreService/ZipLibraryInstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[17], "/cc.arduino.cli.commands.v1.ArduinoCoreService/ZipLibraryInstall", opts...)
if err != nil {
return nil, err
}
......@@ -816,7 +828,7 @@ func (x *arduinoCoreServiceZipLibraryInstallClient) Recv() (*ZipLibraryInstallRe
}
func (c *arduinoCoreServiceClient) GitLibraryInstall(ctx context.Context, in *GitLibraryInstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_GitLibraryInstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[18], "/cc.arduino.cli.commands.v1.ArduinoCoreService/GitLibraryInstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[18], "/cc.arduino.cli.commands.v1.ArduinoCoreService/GitLibraryInstall", opts...)
if err != nil {
return nil, err
}
......@@ -848,7 +860,7 @@ func (x *arduinoCoreServiceGitLibraryInstallClient) Recv() (*GitLibraryInstallRe
}
func (c *arduinoCoreServiceClient) LibraryUninstall(ctx context.Context, in *LibraryUninstallRequest, opts ...grpc.CallOption) (ArduinoCoreService_LibraryUninstallClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[19], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryUninstall", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[19], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryUninstall", opts...)
if err != nil {
return nil, err
}
......@@ -880,7 +892,7 @@ func (x *arduinoCoreServiceLibraryUninstallClient) Recv() (*LibraryUninstallResp
}
func (c *arduinoCoreServiceClient) LibraryUpgradeAll(ctx context.Context, in *LibraryUpgradeAllRequest, opts ...grpc.CallOption) (ArduinoCoreService_LibraryUpgradeAllClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[20], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryUpgradeAll", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[20], "/cc.arduino.cli.commands.v1.ArduinoCoreService/LibraryUpgradeAll", opts...)
if err != nil {
return nil, err
}
......@@ -939,7 +951,7 @@ func (c *arduinoCoreServiceClient) LibraryList(ctx context.Context, in *LibraryL
}
func (c *arduinoCoreServiceClient) Monitor(ctx context.Context, opts ...grpc.CallOption) (ArduinoCoreService_MonitorClient, error) {
stream, err := c.cc.NewStream(ctx, &_ArduinoCoreService_serviceDesc.Streams[21], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Monitor", opts...)
stream, err := c.cc.NewStream(ctx, &ArduinoCoreService_ServiceDesc.Streams[21], "/cc.arduino.cli.commands.v1.ArduinoCoreService/Monitor", opts...)
if err != nil {
return nil, err
}
......@@ -1001,6 +1013,8 @@ type ArduinoCoreServiceServer interface {
Upgrade(*UpgradeRequest, ArduinoCoreService_UpgradeServer) error
// Get the version of Arduino CLI in use.
Version(context.Context, *VersionRequest) (*VersionResponse, error)
// Create a new Sketch
NewSketch(context.Context, *NewSketchRequest) (*NewSketchResponse, error)
// Returns all files composing a Sketch
LoadSketch(context.Context, *LoadSketchRequest) (*LoadSketchResponse, error)
// Creates a zip file containing all files of specified Sketch
......@@ -1103,6 +1117,9 @@ func (UnimplementedArduinoCoreServiceServer) Upgrade(*UpgradeRequest, ArduinoCor
func (UnimplementedArduinoCoreServiceServer) Version(context.Context, *VersionRequest) (*VersionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Version not implemented")
}
func (UnimplementedArduinoCoreServiceServer) NewSketch(context.Context, *NewSketchRequest) (*NewSketchResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method NewSketch not implemented")
}
func (UnimplementedArduinoCoreServiceServer) LoadSketch(context.Context, *LoadSketchRequest) (*LoadSketchResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method LoadSketch not implemented")
}
......@@ -1205,8 +1222,8 @@ type UnsafeArduinoCoreServiceServer interface {
mustEmbedUnimplementedArduinoCoreServiceServer()
}
func RegisterArduinoCoreServiceServer(s *grpc.Server, srv ArduinoCoreServiceServer) {
s.RegisterService(&_ArduinoCoreService_serviceDesc, srv)
func RegisterArduinoCoreServiceServer(s grpc.ServiceRegistrar, srv ArduinoCoreServiceServer) {
s.RegisterService(&ArduinoCoreService_ServiceDesc, srv)
}
func _ArduinoCoreService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
......@@ -1386,6 +1403,24 @@ func _ArduinoCoreService_Version_Handler(srv interface{}, ctx context.Context, d
return interceptor(ctx, in, info, handler)
}
func _ArduinoCoreService_NewSketch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(NewSketchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ArduinoCoreServiceServer).NewSketch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cc.arduino.cli.commands.v1.ArduinoCoreService/NewSketch",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ArduinoCoreServiceServer).NewSketch(ctx, req.(*NewSketchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ArduinoCoreService_LoadSketch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoadSketchRequest)
if err := dec(in); err != nil {
......@@ -2005,7 +2040,10 @@ func _ArduinoCoreService_EnumerateMonitorPortSettings_Handler(srv interface{}, c
return interceptor(ctx, in, info, handler)
}
var _ArduinoCoreService_serviceDesc = grpc.ServiceDesc{
// ArduinoCoreService_ServiceDesc is the grpc.ServiceDesc for ArduinoCoreService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ArduinoCoreService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "cc.arduino.cli.commands.v1.ArduinoCoreService",
HandlerType: (*ArduinoCoreServiceServer)(nil),
Methods: []grpc.MethodDesc{
......@@ -2025,6 +2063,10 @@ var _ArduinoCoreService_serviceDesc = grpc.ServiceDesc{
MethodName: "Version",
Handler: _ArduinoCoreService_Version_Handler,
},
{
MethodName: "NewSketch",
Handler: _ArduinoCoreService_NewSketch_Handler,
},
{
MethodName: "LoadSketch",
Handler: _ArduinoCoreService_LoadSketch_Handler,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment