Skip to content

Commit

Permalink
Add external programmers listing to board details commmand (#927)
Browse files Browse the repository at this point in the history
* Add external programmers listing to board details commmand

* Remove hack to return list of programmers calling upload command
  • Loading branch information
silvanocerza authored Aug 31, 2020
1 parent 21d2533 commit 5ee35c7
Show file tree
Hide file tree
Showing 13 changed files with 404 additions and 294 deletions.
17 changes: 17 additions & 0 deletions cli/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
var tr = i18n.Tr
var showFullDetails bool
var fqbn string
var listProgrammers bool

func initDetailsCommand() *cobra.Command {
var detailsCommand = &cobra.Command{
Expand All @@ -47,6 +48,7 @@ func initDetailsCommand() *cobra.Command {

detailsCommand.Flags().BoolVarP(&showFullDetails, "full", "f", false, tr("Show full board details"))
detailsCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
detailsCommand.Flags().BoolVarP(&listProgrammers, "list-programmers", "", false, tr("Show list of available programmers"))
// detailsCommand.MarkFlagRequired("fqbn") // enable once `board details <fqbn>` is removed

return detailsCommand
Expand Down Expand Up @@ -89,6 +91,16 @@ func (dr detailsResult) Data() interface{} {

func (dr detailsResult) String() string {
details := dr.details

if listProgrammers {
t := table.New()
t.AddRow(tr("Id"), tr("Programmer name"))
for _, programmer := range details.Programmers {
t.AddRow(programmer.GetId(), programmer.GetName())
}
return t.Render()
}

// Table is 4 columns wide:
// | | | | |
// Board name: Arduino Nano
Expand Down Expand Up @@ -180,5 +192,10 @@ func (dr detailsResult) String() string {
}
}

t.AddRow(tr("Programmers:"), tr("Id"), tr("Name"))
for _, programmer := range details.Programmers {
t.AddRow("", programmer.GetId(), programmer.GetName())
}

return t.Render()
}
15 changes: 0 additions & 15 deletions cli/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ func run(command *cobra.Command, args []string) {
os.Exit(errorcodes.ErrGeneric)
}

if programmer == "list" {
resp, err := upload.ListProgrammersAvailableForUpload(context.Background(), &rpc.ListProgrammersAvailableForUploadReq{
Instance: instance,
Fqbn: fqbn,
})
if err != nil {
feedback.Errorf("Error listing programmers: %v", err)
os.Exit(errorcodes.ErrGeneric)
}
feedback.PrintResult(&programmersList{
Programmers: resp.GetProgrammers(),
})
os.Exit(0)
}

var path *paths.Path
if len(args) > 0 {
path = paths.New(args[0])
Expand Down
9 changes: 9 additions & 0 deletions commands/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,14 @@ func Details(ctx context.Context, req *rpc.BoardDetailsReq) (*rpc.BoardDetailsRe
})
}

details.Programmers = []*rpc.Programmer{}
for id, p := range boardPlatform.Programmers {
details.Programmers = append(details.Programmers, &rpc.Programmer{
Platform: boardPlatform.Platform.Name,
Id: id,
Name: p.Name,
})
}

return details, nil
}
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
Expand Down Expand Up @@ -309,6 +311,8 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90 h1:7THRSvPuzF1bql5kyFzX0JM0vpGhwuhskgJrJsbZ80Y=
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
75 changes: 48 additions & 27 deletions i18n/data/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ msgstr "Aliases:"
msgid "Available Commands:"
msgstr "Available Commands:"

#: cli/board/details.go:112
#: cli/board/details.go:124
msgid "Board name:"
msgstr "Board name:"

#: cli/board/details.go:114
#: cli/board/details.go:126
msgid "Board version:"
msgstr "Board version:"

#: cli/board/details.go:157
#: cli/board/details.go:169
msgid "Checksum:"
msgstr "Checksum:"

#: cli/board/details.go:58
#: cli/board/details.go:73
#: cli/board/details.go:60
#: cli/board/details.go:75
msgid "Error getting board details: %v"
msgstr "Error getting board details: %v"

#: cli/usage.go:27
msgid "Examples:"
msgstr "Examples:"

#: cli/board/details.go:155
#: cli/board/details.go:167
msgid "File:"
msgstr "File:"

Expand All @@ -46,87 +46,108 @@ msgstr "Flags:"
msgid "Global Flags:"
msgstr "Global Flags:"

#: cli/board/details.go:125
#: cli/board/details.go:97
#: cli/board/details.go:195
msgid "Id"
msgstr "Id"

#: cli/board/details.go:137
msgid "Identification properties:"
msgstr "Identification properties:"

#: cli/board/details.go:154
#: cli/board/details.go:195
msgid "Name"
msgstr "Name"

#: cli/board/details.go:166
msgid "OS:"
msgstr "OS:"

#: cli/board/details.go:118
#: cli/board/details.go:130
msgid "Official Arduino board:"
msgstr "Official Arduino board:"

#: cli/board/details.go:166
#: cli/board/details.go:178
msgid "Option:"
msgstr "Option:"

#: cli/board/details.go:134
#: cli/board/details.go:146
msgid "Package URL:"
msgstr "Package URL:"

#: cli/board/details.go:133
#: cli/board/details.go:145
msgid "Package maintainer:"
msgstr "Package maintainer:"

#: cli/board/details.go:132
#: cli/board/details.go:144
msgid "Package name:"
msgstr "Package name:"

#: cli/board/details.go:136
#: cli/board/details.go:148
msgid "Package online help:"
msgstr "Package online help:"

#: cli/board/details.go:135
#: cli/board/details.go:147
msgid "Package website:"
msgstr "Package website:"

#: cli/board/details.go:142
#: cli/board/details.go:154
msgid "Platform URL:"
msgstr "Platform URL:"

#: cli/board/details.go:141
#: cli/board/details.go:153
msgid "Platform architecture:"
msgstr "Platform architecture:"

#: cli/board/details.go:140
#: cli/board/details.go:152
msgid "Platform category:"
msgstr "Platform category:"

#: cli/board/details.go:147
#: cli/board/details.go:159
msgid "Platform checksum:"
msgstr "Platform checksum:"

#: cli/board/details.go:143
#: cli/board/details.go:155
msgid "Platform file name:"
msgstr "Platform file name:"

#: cli/board/details.go:139
#: cli/board/details.go:151
msgid "Platform name:"
msgstr "Platform name:"

#: cli/board/details.go:145
#: cli/board/details.go:157
msgid "Platform size (bytes):"
msgstr "Platform size (bytes):"

#: cli/board/details.go:41
#: cli/board/details.go:42
msgid "Print details about a board."
msgstr "Print details about a board."

#: cli/board/details.go:151
#: cli/board/details.go:97
msgid "Programmer name"
msgstr "Programmer name"

#: cli/board/details.go:195
msgid "Programmers:"
msgstr "Programmers:"

#: cli/board/details.go:163
msgid "Required tool:"
msgstr "Required tool:"

#: cli/board/details.go:48
#: cli/board/details.go:49
msgid "Show full board details"
msgstr "Show full board details"

#: cli/board/details.go:42
#: cli/board/details.go:43
msgid "Show information about a board, in particular if the board has options to be specified in the FQBN."
msgstr "Show information about a board, in particular if the board has options to be specified in the FQBN."

#: cli/board/details.go:156
#: cli/board/details.go:51
msgid "Show list of available programmers"
msgstr "Show list of available programmers"

#: cli/board/details.go:168
msgid "Size (bytes):"
msgstr "Size (bytes):"

Expand Down
Loading

0 comments on commit 5ee35c7

Please sign in to comment.