@@ -21,6 +21,7 @@ import (
21
21
"encoding/json"
22
22
"os"
23
23
24
+ "github.com/arduino/arduino-cli/arduino/cores"
24
25
"github.com/arduino/arduino-cli/output"
25
26
26
27
"github.com/arduino/arduino-cli/commands"
@@ -42,8 +43,13 @@ func initDetailsCommand() *cobra.Command {
42
43
43
44
func runDetailsCommand (cmd * cobra.Command , args []string ) {
44
45
pm := commands .InitPackageManager ()
45
- fqbnIn := args [0 ]
46
- board , err := pm .FindBoardWithFQBN (fqbnIn )
46
+ fqbn , err := cores .ParseFQBN (args [0 ])
47
+ if err != nil {
48
+ formatter .PrintError (err , "Error parsing fqbn" )
49
+ os .Exit (commands .ErrBadArgument )
50
+ }
51
+
52
+ _ , _ , board , _ , _ , err := pm .ResolveFQBN (fqbn )
47
53
if err != nil {
48
54
formatter .PrintError (err , "Error loading board data" )
49
55
os .Exit (commands .ErrBadArgument )
@@ -53,17 +59,22 @@ func runDetailsCommand(cmd *cobra.Command, args []string) {
53
59
details .Name = board .Name ()
54
60
details .ConfigOptions = []* boardConfigOption {}
55
61
options := board .GetConfigOptions ()
62
+ t := true
56
63
for _ , option := range options .Keys () {
57
64
configOption := & boardConfigOption {}
58
65
configOption .Option = option
59
66
configOption .OptionLabel = options .Get (option )
67
+ selected , hasSelected := fqbn .Configs .GetOk (option )
68
+
60
69
values := board .GetConfigOptionValues (option )
61
70
for i , value := range values .Keys () {
62
71
configValue := & boardConfigValue {}
63
- if i == 0 {
64
- t := true
65
- configValue .Default = & t
72
+ if hasSelected && value == selected {
73
+ configValue .Selected = & t
74
+ } else if ! hasSelected && i == 0 {
75
+ configValue .Selected = & t
66
76
}
77
+
67
78
configValue .Value = value
68
79
configValue .ValueLabel = values .Get (value )
69
80
configOption .Values = append (configOption .Values , configValue )
@@ -89,7 +100,7 @@ type boardConfigOption struct {
89
100
type boardConfigValue struct {
90
101
Value string
91
102
ValueLabel string
92
- Default * bool `json:",omitempty"`
103
+ Selected * bool `json:",omitempty"`
93
104
}
94
105
95
106
func (details * boardDetails ) EmitJSON () string {
@@ -103,12 +114,23 @@ func (details *boardDetails) EmitJSON() string {
103
114
104
115
func (details * boardDetails ) EmitTerminal () string {
105
116
table := output .NewTable ()
106
- table .AddRow ("Board name:" , output . Red ( details .Name ) )
117
+ table .AddRow ("Board name:" , details .Name )
107
118
table .SetColumnWidthMode (1 , output .Average )
108
119
for _ , option := range details .ConfigOptions {
109
- table .AddRow ("Option:" , option .OptionLabel )
120
+ table .AddRow ()
121
+ table .AddRow ("Option:" ,
122
+ option .OptionLabel ,
123
+ "" , option .Option )
110
124
for _ , value := range option .Values {
111
- table .AddRow ("" , value .ValueLabel , option .Option + "=" + value .Value )
125
+ if value .Selected != nil {
126
+ table .AddRow ("" ,
127
+ output .Green (value .ValueLabel ),
128
+ output .Green ("✔" ), output .Green (option .Option + "=" + value .Value ))
129
+ } else {
130
+ table .AddRow ("" ,
131
+ value .ValueLabel ,
132
+ "" , option .Option + "=" + value .Value )
133
+ }
112
134
}
113
135
}
114
136
return table .Render ()
0 commit comments