Skip to content
Merged
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
Add default_programmer field to sketch project
  • Loading branch information
MatteoPologruto committed Jan 18, 2024
commit 69513ada15ff6a2aa4252e71d8e237e62543e2df
36 changes: 21 additions & 15 deletions internal/arduino/sketch/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ import (

// projectRaw is a support struct used only to unmarshal the yaml
type projectRaw struct {
ProfilesRaw yaml.Node `yaml:"profiles"`
DefaultProfile string `yaml:"default_profile"`
DefaultFqbn string `yaml:"default_fqbn"`
DefaultPort string `yaml:"default_port,omitempty"`
DefaultProtocol string `yaml:"default_protocol,omitempty"`
ProfilesRaw yaml.Node `yaml:"profiles"`
DefaultProfile string `yaml:"default_profile"`
DefaultFqbn string `yaml:"default_fqbn"`
DefaultPort string `yaml:"default_port,omitempty"`
DefaultProtocol string `yaml:"default_protocol,omitempty"`
DefaultProgrammer string `yaml:"default_programmer,omitempty"`
}

// Project represents the sketch project file
type Project struct {
Profiles []*Profile
DefaultProfile string
DefaultFqbn string
DefaultPort string
DefaultProtocol string
Profiles []*Profile
DefaultProfile string
DefaultFqbn string
DefaultPort string
DefaultProtocol string
DefaultProgrammer string
}

// AsYaml outputs the sketch project file as YAML
Expand All @@ -69,6 +71,9 @@ func (p *Project) AsYaml() string {
if p.DefaultProtocol != "" {
res += fmt.Sprintf("default_protocol: %s\n", p.DefaultProtocol)
}
if p.DefaultProgrammer != "" {
res += fmt.Sprintf("default_programmer: %s\n", p.DefaultProgrammer)
}
return res
}

Expand Down Expand Up @@ -280,10 +285,11 @@ func LoadProjectFile(file *paths.Path) (*Project, error) {
return nil, err
}
return &Project{
Profiles: profiles,
DefaultProfile: raw.DefaultProfile,
DefaultFqbn: raw.DefaultFqbn,
DefaultPort: raw.DefaultPort,
DefaultProtocol: raw.DefaultProtocol,
Profiles: profiles,
DefaultProfile: raw.DefaultProfile,
DefaultFqbn: raw.DefaultFqbn,
DefaultPort: raw.DefaultPort,
DefaultProtocol: raw.DefaultProtocol,
DefaultProgrammer: raw.DefaultProgrammer,
}, nil
}