Skip to content

Commit 69513ad

Browse files
Add default_programmer field to sketch project
1 parent e4668e7 commit 69513ad

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

internal/arduino/sketch/profiles.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@ import (
3232

3333
// projectRaw is a support struct used only to unmarshal the yaml
3434
type projectRaw struct {
35-
ProfilesRaw yaml.Node `yaml:"profiles"`
36-
DefaultProfile string `yaml:"default_profile"`
37-
DefaultFqbn string `yaml:"default_fqbn"`
38-
DefaultPort string `yaml:"default_port,omitempty"`
39-
DefaultProtocol string `yaml:"default_protocol,omitempty"`
35+
ProfilesRaw yaml.Node `yaml:"profiles"`
36+
DefaultProfile string `yaml:"default_profile"`
37+
DefaultFqbn string `yaml:"default_fqbn"`
38+
DefaultPort string `yaml:"default_port,omitempty"`
39+
DefaultProtocol string `yaml:"default_protocol,omitempty"`
40+
DefaultProgrammer string `yaml:"default_programmer,omitempty"`
4041
}
4142

4243
// Project represents the sketch project file
4344
type Project struct {
44-
Profiles []*Profile
45-
DefaultProfile string
46-
DefaultFqbn string
47-
DefaultPort string
48-
DefaultProtocol string
45+
Profiles []*Profile
46+
DefaultProfile string
47+
DefaultFqbn string
48+
DefaultPort string
49+
DefaultProtocol string
50+
DefaultProgrammer string
4951
}
5052

5153
// AsYaml outputs the sketch project file as YAML
@@ -69,6 +71,9 @@ func (p *Project) AsYaml() string {
6971
if p.DefaultProtocol != "" {
7072
res += fmt.Sprintf("default_protocol: %s\n", p.DefaultProtocol)
7173
}
74+
if p.DefaultProgrammer != "" {
75+
res += fmt.Sprintf("default_programmer: %s\n", p.DefaultProgrammer)
76+
}
7277
return res
7378
}
7479

@@ -280,10 +285,11 @@ func LoadProjectFile(file *paths.Path) (*Project, error) {
280285
return nil, err
281286
}
282287
return &Project{
283-
Profiles: profiles,
284-
DefaultProfile: raw.DefaultProfile,
285-
DefaultFqbn: raw.DefaultFqbn,
286-
DefaultPort: raw.DefaultPort,
287-
DefaultProtocol: raw.DefaultProtocol,
288+
Profiles: profiles,
289+
DefaultProfile: raw.DefaultProfile,
290+
DefaultFqbn: raw.DefaultFqbn,
291+
DefaultPort: raw.DefaultPort,
292+
DefaultProtocol: raw.DefaultProtocol,
293+
DefaultProgrammer: raw.DefaultProgrammer,
288294
}, nil
289295
}

0 commit comments

Comments
 (0)