8000 Added possibility to set custom properties on upload/burn-bootloader/debug commands. by cmaglie · Pull Request #2693 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

Added possibility to set custom properties on upload/burn-bootloader/debug commands. #2693

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
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added --upload-properties flag to CLI upload and burn-bootloader
…commands.
  • Loading branch information
cmaglie committed Aug 21, 2024
commit 76ff3d6aa18523deb1b44287c14a9343cba963ce
30 changes: 17 additions & 13 deletions internal/cli/burnbootloader/burnbootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ import (
)

var (
fqbn arguments.Fqbn
port arguments.Port
verbose bool
verify bool
programmer arguments.Programmer
dryRun bool
fqbn arguments.Fqbn
port arguments.Port
verbose bool
verify bool
programmer arguments.Programmer
dryRun bool
uploadProperties []string
)

// NewCommand created a new `burn-bootloader` command
Expand All @@ -56,6 +57,8 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
fqbn.AddToCommand(burnBootloaderCommand, srv)
port.AddToCommand(burnBootloaderCommand, srv)
programmer.AddToCommand(burnBootloaderCommand, srv)
burnBootloaderCommand.Flags().StringArrayVar(&uploadProperties, "upload-property", []string{},
i18n.Tr("Override an upload property with a custom value. Can be used multiple times for multiple properties."))
burnBootloaderCommand.Flags().BoolVarP(&verify, "verify", "t", false, i18n.Tr("Verify uploaded binary after the upload."))
burnBootloaderCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, i18n.Tr("Turns on verbose mode."))
burnBootloaderCommand.Flags().BoolVar(&dryRun, "dry-run", false, i18n.Tr("Do not perform the actual upload, just log out actions"))
Expand All @@ -78,13 +81,14 @@ func runBootloaderCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer)
stdOut, stdErr, res := feedback.OutputStreams()
stream := commands.BurnBootloaderToServerStreams(ctx, stdOut, stdErr)
if err := srv.BurnBootloader(&rpc.BurnBootloaderRequest{
Instance: instance,
Fqbn: fqbn.String(),
Port: discoveryPort,
Verbose: verbose,
Verify: verify,
Programmer: programmer.String(ctx, instance, srv, fqbn.String()),
DryRun: dryRun,
Instance: instance,
Fqbn: fqbn.String(),
Port: discoveryPort,
Verbose: verbose,
Verify: verify,
Programmer: programmer.String(ctx, instance, srv, fqbn.String()),
UploadProperties: uploadProperties,
DryRun: dryRun,
}, stream); err != nil {
errcode := feedback.ErrGeneric
if errors.Is(err, &cmderrors.ProgrammerRequiredForUploadError{}) {
Expand Down
44 changes: 24 additions & 20 deletions internal/cli/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ import (
)

var (
fqbnArg arguments.Fqbn
portArgs arguments.Port
profileArg arguments.Profile
verbose bool
verify bool
importDir string
importFile string
programmer arguments.Programmer
dryRun bool
fqbnArg arguments.Fqbn
portArgs arguments.Port
profileArg arguments.Profile
verbose bool
verify bool
importDir string
importFile string
programmer arguments.Programmer
dryRun bool
uploadProperties []string
)

// NewCommand created a new `upload` command
Expand All @@ -71,6 +72,8 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
profileArg.AddToCommand(uploadCommand, srv)
uploadCommand.Flags().StringVarP(&importDir, "input-dir", "", "", i18n.Tr("Directory containing binaries to upload."))
uploadCommand.Flags().StringVarP(&importFile, "input-file", "i", "", i18n.Tr("Binary file to upload."))
uploadCommand.Flags().StringArrayVar(&uploadProperties, "upload-property", []string{},
i18n.Tr("Override an upload property with a custom value. Can be used multiple times for multiple properties."))
uploadCommand.Flags().BoolVarP(&verify, "verify", "t", false, i18n.Tr("Verify uploaded binary after the upload."))
uploadCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, i18n.Tr("Optional, turns on verbose mode."))
programmer.AddToCommand(uploadCommand, srv)
Expand Down Expand Up @@ -184,17 +187,18 @@ func runUploadCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, arg

stdOut, stdErr, stdIOResult := feedback.OutputStreams()
req := &rpc.UploadRequest{
Instance: inst,
Fqbn: fqbn,
SketchPath: path,
Port: port,
Verbose: verbose,
Verify: verify,
ImportFile: importFile,
ImportDir: importDir,
Programmer: prog,
DryRun: dryRun,
UserFields: fields,
Instance: inst,
Fqbn: fqbn,
SketchPath: path,
Port: port,
Verbose: verbose,
Verify: verify,
ImportFile: importFile,
ImportDir: importDir,
Programmer: prog,
DryRun: dryRun,
UserFields: fields,
UploadProperties: uploadProperties,
}
stream, streamResp := commands.UploadToServerStreams(ctx, stdOut, stdErr)
if err := srv.Upload(req, stream); err != nil {
Expand Down
0