Skip to content
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
InitSketchPath make warnings configurable
  • Loading branch information
alessio-perugini committed Oct 24, 2023
commit 6c0a0f304ca582cee000c6ec9fd75a100adc4280
8 changes: 5 additions & 3 deletions internal/cli/arguments/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// InitSketchPath returns an instance of paths.Path pointing to sketchPath.
// If sketchPath is an empty string returns the current working directory.
// In both cases it warns the user if he's using deprecated files
func InitSketchPath(path string) (sketchPath *paths.Path) {
func InitSketchPath(path string, printWarnings bool) (sketchPath *paths.Path) {
if path != "" {
sketchPath = paths.New(path)
} else {
Expand All @@ -36,8 +36,10 @@ func InitSketchPath(path string) (sketchPath *paths.Path) {
logrus.Infof("Reading sketch from dir: %s", wd)
sketchPath = wd
}
if msg := sk.WarnDeprecatedFiles(sketchPath); msg != "" {
feedback.Warning(msg)
if printWarnings {
if msg := sk.WarnDeprecatedFiles(sketchPath); msg != "" {
feedback.Warning(msg)
}
}
return sketchPath
}
2 changes: 1 addition & 1 deletion internal/cli/board/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func initAttachCommand() *cobra.Command {
}

func runAttachCommand(path string, port *arguments.Port, fqbn string) {
sketchPath := arguments.InitSketchPath(path)
sketchPath := arguments.InitSketchPath(path, true)

portAddress, portProtocol, _ := port.GetPortAddressAndProtocol(nil, "", "")
newDefaults, err := sketch.SetSketchDefaults(context.Background(), &rpc.SetSketchDefaultsRequest{
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
path = args[0]
}

sketchPath := arguments.InitSketchPath(path)
sketchPath := arguments.InitSketchPath(path, true)

sk, err := sketch.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runDebugCommand(command *cobra.Command, args []string) {
path = args[0]
}

sketchPath := arguments.InitSketchPath(path)
sketchPath := arguments.InitSketchPath(path, true)
sk, err := sketch.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()})
if err != nil {
feedback.FatalError(err, feedback.ErrGeneric)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func runMonitorCmd(
// If both {--port --profile} are set we read the fqbn in the following order: profile -> default_fqbn -> discovery
// If only --port is set we read the fqbn in the following order: default_fqbn -> discovery
// If only --fqbn is set we read the port in the following order: default_port
sketchPath := arguments.InitSketchPath(sketchPathArg)
sketchPath := arguments.InitSketchPath(sketchPathArg, false)
sketch, err := sk.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()})
if err != nil && !portArgs.IsPortFlagSet() {
feedback.Fatal(
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func runUploadCommand(args []string, uploadFieldsArgs map[string]string) {
if len(args) > 0 {
path = args[0]
}
sketchPath := arguments.InitSketchPath(path)
sketchPath := arguments.InitSketchPath(path, true)

if msg := sk.WarnDeprecatedFiles(sketchPath); importDir == "" && importFile == "" && msg != "" {
feedback.Warning(msg)
Expand Down