Commit 3ff8e090 authored by Cristian Maglie's avatar Cristian Maglie

Moved a batch of function from commands/* subpackage to commands (part 3)

parent 3d8f50a5
......@@ -27,7 +27,6 @@ import (
"github.com/arduino/arduino-cli/commands/monitor"
"github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/commands/updatecheck"
"github.com/arduino/arduino-cli/commands/upload"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/metadata"
......@@ -299,7 +298,7 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin
Message: &rpc.UploadResponse_ErrStream{ErrStream: data},
})
})
res, err := upload.Upload(stream.Context(), req, outStream, errStream)
res, err := Upload(stream.Context(), req, outStream, errStream)
outStream.Close()
errStream.Close()
if res != nil {
......@@ -329,7 +328,7 @@ func (s *ArduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
},
})
})
err := upload.UsingProgrammer(stream.Context(), req, outStream, errStream)
err := UploadUsingProgrammer(stream.Context(), req, outStream, errStream)
outStream.Close()
errStream.Close()
if err != nil {
......@@ -340,7 +339,7 @@ func (s *ArduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
// SupportedUserFields FIXMEDOC
func (s *ArduinoCoreServerImpl) SupportedUserFields(ctx context.Context, req *rpc.SupportedUserFieldsRequest) (*rpc.SupportedUserFieldsResponse, error) {
res, err := upload.SupportedUserFields(ctx, req)
res, err := SupportedUserFields(ctx, req)
return res, convertErrorToRPCStatus(err)
}
......@@ -361,7 +360,7 @@ func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
},
})
})
resp, err := upload.BurnBootloader(stream.Context(), req, outStream, errStream)
resp, err := BurnBootloader(stream.Context(), req, outStream, errStream)
outStream.Close()
errStream.Close()
if err != nil {
......@@ -372,7 +371,7 @@ func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
// ListProgrammersAvailableForUpload FIXMEDOC
func (s *ArduinoCoreServerImpl) ListProgrammersAvailableForUpload(ctx context.Context, req *rpc.ListProgrammersAvailableForUploadRequest) (*rpc.ListProgrammersAvailableForUploadResponse, error) {
resp, err := upload.ListProgrammersAvailableForUpload(ctx, req)
resp, err := ListProgrammersAvailableForUpload(ctx, req)
return resp, convertErrorToRPCStatus(err)
}
......
......@@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.
package upload
package commands
import (
"context"
......@@ -31,7 +31,6 @@ import (
"github.com/arduino/arduino-cli/internal/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/internal/arduino/globals"
"github.com/arduino/arduino-cli/internal/arduino/sketch"
"github.com/arduino/arduino-cli/internal/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap"
......@@ -40,8 +39,6 @@ import (
"github.com/sirupsen/logrus"
)
var tr = i18n.Tr
// SupportedUserFields returns a SupportedUserFieldsResponse containing all the UserFields supported
// by the upload tools needed by the board using the protocol specified in SupportedUserFieldsRequest.
func SupportedUserFields(ctx context.Context, req *rpc.SupportedUserFieldsRequest) (*rpc.SupportedUserFieldsResponse, error) {
......@@ -179,8 +176,8 @@ func Upload(ctx context.Context, req *rpc.UploadRequest, outStream io.Writer, er
}, nil
}
// UsingProgrammer FIXMEDOC
func UsingProgrammer(ctx context.Context, req *rpc.UploadUsingProgrammerRequest, outStream io.Writer, errStream io.Writer) error {
// UploadUsingProgrammer FIXMEDOC
func UploadUsingProgrammer(ctx context.Context, req *rpc.UploadUsingProgrammerRequest, outStream io.Writer, errStream io.Writer) error {
logrus.Tracef("Upload using programmer %s on %s started", req.GetSketchPath(), req.GetFqbn())
if req.GetProgrammer() == "" {
......
......@@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.
package upload
package commands
import (
"context"
......
......@@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.
package upload
package commands
import (
"context"
......
......@@ -19,7 +19,6 @@ import (
"context"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/upload"
"github.com/arduino/arduino-cli/internal/cli/instance"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)
......@@ -58,7 +57,7 @@ func GetInstalledProgrammers() []string {
installedProgrammers := make(map[string]string)
for _, board := range list.GetBoards() {
programmers, _ := upload.ListProgrammersAvailableForUpload(context.Background(), &rpc.ListProgrammersAvailableForUploadRequest{
programmers, _ := commands.ListProgrammersAvailableForUpload(context.Background(), &rpc.ListProgrammersAvailableForUploadRequest{
Instance: inst,
Fqbn: board.GetFqbn(),
})
......
......@@ -20,8 +20,8 @@ import (
"errors"
"os"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/cmderrors"
"github.com/arduino/arduino-cli/commands/upload"
"github.com/arduino/arduino-cli/internal/cli/arguments"
"github.com/arduino/arduino-cli/internal/cli/feedback"
"github.com/arduino/arduino-cli/internal/cli/instance"
......@@ -75,7 +75,7 @@ func runBootloaderCommand(command *cobra.Command, args []string) {
}
stdOut, stdErr, res := feedback.OutputStreams()
if _, err := upload.BurnBootloader(context.Background(), &rpc.BurnBootloaderRequest{
if _, err := commands.BurnBootloader(context.Background(), &rpc.BurnBootloaderRequest{
Instance: instance,
Fqbn: fqbn.String(),
Port: discoveryPort,
......
......@@ -27,7 +27,6 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/cmderrors"
"github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/commands/upload"
"github.com/arduino/arduino-cli/internal/cli/arguments"
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/cli/feedback"
......@@ -249,7 +248,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
var uploadRes *rpc.UploadResult
if compileError == nil && uploadAfterCompile {
userFieldRes, err := upload.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
userFieldRes, err := commands.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
Instance: inst,
Fqbn: fqbn,
Protocol: port.GetProtocol(),
......@@ -288,7 +287,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
UserFields: fields,
}
if res, err := upload.Upload(context.Background(), uploadRequest, stdOut, stdErr); err != nil {
if res, err := commands.Upload(context.Background(), uploadRequest, stdOut, stdErr); err != nil {
errcode := feedback.ErrGeneric
if errors.Is(err, &cmderrors.ProgrammerRequiredForUploadError{}) {
errcode = feedback.ErrMissingProgrammer
......
......@@ -25,7 +25,6 @@ import (
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/cmderrors"
sk "github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/commands/upload"
"github.com/arduino/arduino-cli/internal/cli/arguments"
"github.com/arduino/arduino-cli/internal/cli/feedback"
"github.com/arduino/arduino-cli/internal/cli/feedback/result"
......@@ -117,7 +116,7 @@ func runUploadCommand(args []string, uploadFieldsArgs map[string]string) {
defaultProtocol := sketch.GetDefaultProtocol()
fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, inst, defaultFQBN, defaultAddress, defaultProtocol)
userFieldRes, err := upload.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
userFieldRes, err := commands.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{
Instance: inst,
Fqbn: fqbn,
Protocol: port.GetProtocol(),
......@@ -198,7 +197,7 @@ func runUploadCommand(args []string, uploadFieldsArgs map[string]string) {
DryRun: dryRun,
UserFields: fields,
}
if res, err := upload.Upload(context.Background(), req, stdOut, stdErr); err != nil {
if res, err := commands.Upload(context.Background(), req, stdOut, stdErr); err != nil {
errcode := feedback.ErrGeneric
if errors.Is(err, &cmderrors.ProgrammerRequiredForUploadError{}) {
errcode = feedback.ErrMissingProgrammer
......
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