From f0b9da8a0508356d8e2adc76d6987394b5bab6b8 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 11 Jun 2019 10:47:46 +0200 Subject: [PATCH 01/18] first draft --- .drone.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000000..bc428f47843 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,9 @@ +kind: pipeline +name: default + +steps: +- name: test + image: golang + commands: + - curl -sL https://taskfile.dev/install.sh | sh + - task test \ No newline at end of file From 0658652c06e7291e22ad3cbafcc422e71c239555 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 11 Jun 2019 10:48:56 +0200 Subject: [PATCH 02/18] path to task --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bc428f47843..53a306f9bc3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,4 +6,4 @@ steps: image: golang commands: - curl -sL https://taskfile.dev/install.sh | sh - - task test \ No newline at end of file + - ./bin/task test \ No newline at end of file From c0865e20cd9484c0d372dfbb6d6e0159b74d5fc5 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 11 Jun 2019 10:54:30 +0200 Subject: [PATCH 03/18] try excluding legacy --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 53a306f9bc3..b1fb1b400fd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,4 +6,4 @@ steps: image: golang commands: - curl -sL https://taskfile.dev/install.sh | sh - - ./bin/task test \ No newline at end of file + - ./bin/task test TARGETS=$(go list ./... | grep -v /legacy/) \ No newline at end of file From 378f20b432bb1ec1142999ee68806a1c8887f9eb Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 12 Jun 2019 16:38:52 +0200 Subject: [PATCH 04/18] added dockerfile --- Dockerfiles/CI/Dockerfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Dockerfiles/CI/Dockerfile diff --git a/Dockerfiles/CI/Dockerfile b/Dockerfiles/CI/Dockerfile new file mode 100644 index 00000000000..f1a20239d0c --- /dev/null +++ b/Dockerfiles/CI/Dockerfile @@ -0,0 +1 @@ +FROM golang:1.12-alpine \ No newline at end of file From 2de034ba31408f06f799c2aa14ae31d1d42c4e49 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 12 Jun 2019 17:14:24 +0200 Subject: [PATCH 05/18] use custom image --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index b1fb1b400fd..275ff1b535c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: default steps: - name: test - image: golang + image: arduino/arduino-cli:drone-0.0.0 commands: - curl -sL https://taskfile.dev/install.sh | sh - ./bin/task test TARGETS=$(go list ./... | grep -v /legacy/) \ No newline at end of file From b0d1f7e094ca88438a1d7ad7f4674b741f419544 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 12 Jun 2019 18:24:03 +0200 Subject: [PATCH 06/18] install task inside container --- Dockerfiles/CI/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfiles/CI/Dockerfile b/Dockerfiles/CI/Dockerfile index f1a20239d0c..8110af0a949 100644 --- a/Dockerfiles/CI/Dockerfile +++ b/Dockerfiles/CI/Dockerfile @@ -1 +1,4 @@ -FROM golang:1.12-alpine \ No newline at end of file +FROM golang:1.12 + +RUN set -ex \ + && curl -sL https://taskfile.dev/install.sh | sh \ No newline at end of file From 25dc90aa3190ac04389ee75b59cf990dd341752d Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 12 Jun 2019 18:32:42 +0200 Subject: [PATCH 07/18] bump image --- .drone.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 275ff1b535c..a4e004eceb4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,6 @@ name: default steps: - name: test - image: arduino/arduino-cli:drone-0.0.0 + image: arduino/arduino-cli:drone-0.0.1 commands: - - curl -sL https://taskfile.dev/install.sh | sh - - ./bin/task test TARGETS=$(go list ./... | grep -v /legacy/) \ No newline at end of file + - task test TARGETS=$(go list ./... | grep -v /legacy/) \ No newline at end of file From d22ccefb1f828bbbb185a690aca59196c8a87880 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Wed, 12 Jun 2019 18:36:12 +0200 Subject: [PATCH 08/18] remove shell expansion --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a4e004eceb4..e3d9ee9b22d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,4 +5,4 @@ steps: - name: test image: arduino/arduino-cli:drone-0.0.1 commands: - - task test TARGETS=$(go list ./... | grep -v /legacy/) \ No newline at end of file + - task test \ No newline at end of file From b09d5c266d3e3eafd31723d5ef6a6aefcbc9e44c Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 12:58:30 +0200 Subject: [PATCH 09/18] replace golangci-lint with govet and golint go-task task going in the direction of removing travis.ci in favour of drone io, and in order to have a clean linting check output, golangci-lint was removed because the output for this codebase was too confusing --- .golangci.yml | 40 ---------------------------------------- .travis.yml | 7 +++---- Taskfile.yml | 24 ++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index fd1caa762db..00000000000 --- a/.golangci.yml +++ /dev/null @@ -1,40 +0,0 @@ -run: - skip-dirs: - - legacy - -linters-settings: - govet: - check-shadowing: true - golint: - min-confidence: 0 - gocyclo: - min-complexity: 13 # Should be 10 but was brought to 13 to speed up the development - maligned: - suggest-new: true - dupl: - threshold: 100 - goconst: - min-len: 2 - min-occurrences: 2 - lll: - line-length: 160 - - misspell: - locale: US - -linters: - enable-all: true - disable: - - goimports - - gocritic - - gochecknoglobals - - gosec - - deadcode - - dupl - - errcheck - - goconst - - gocyclo - - govet - - maligned - - megacheck - - unparam diff --git a/.travis.yml b/.travis.yml index f96024ab445..56824ca2e94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,10 @@ env: # Anything in before_script that returns a nonzero exit code will flunk the # build and immediately stop. It's sorta like having set -e enabled in bash. # Make sure golangci-lint is vendored. -before_install: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.16.0 +install: - curl -sL https://taskfile.dev/install.sh | sh - -install: true + - go get github.com/golangci/govet + - go get golang.org/x/lint/golint script: # Check if the code is formatted diff --git a/Taskfile.yml b/Taskfile.yml index aea81983b6a..5bd6f0fd7e1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,7 +15,7 @@ tasks: test-unit: desc: Run unit tests only cmds: - - go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} + - go test -race -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} test-integration: desc: Run integration tests only @@ -27,6 +27,23 @@ tasks: cmds: - go test {{ default "-v" .GOFLAGS }} ./legacy/... + check: + desc: Run all the checks + cmds: + - task: check-fmt + - task: check-lint + + check-fmt: + desc: Run go fmt as a test with return code + cmds: + - test -z $(go fmt {{ default "./..." .TARGETS }}) + + check-lint: + desc: Run linters + cmds: + - go vet {{ default "./..." .TARGETS }} + - golint {{.GOLINTFLAGS}} {{ default "./..." .TARGETS }} + vars: DEFAULT_TARGETS: "./arduino/... ./auth/... ./cli/... ./commands/... ./executils/... ./version/..." @@ -44,4 +61,7 @@ vars: TEST_COMMIT: "deadbeef" TEST_LDFLAGS: > -ldflags '-X github.com/arduino/arduino-cli/version.versionString={{.TEST_VERSIONSTRING}} - -X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}' \ No newline at end of file + -X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}' + + # check-lint vars + GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status" \ No newline at end of file From 9f87c4228dff6972c91ac9ba83a54db7023976be Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 15:07:33 +0200 Subject: [PATCH 10/18] refactor task check and add task check-legacy in order to be aligned with test task style we will have a legacy (ugly) lint output if requested and meanwhile we will focus on the "new refactored part" of the code with lint and fmt to speed up the development and refactoring --- Taskfile.yml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 5bd6f0fd7e1..1ed010e758f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -23,26 +23,23 @@ tasks: - go test -run Integration {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}} test-legacy: - desc: Run tests for the `legacy` package + desc: Run tests cmds: - go test {{ default "-v" .GOFLAGS }} ./legacy/... check: - desc: Run all the checks + desc: Check fmt and lint, `legacy` will be skipped cmds: - - task: check-fmt - - task: check-lint + - test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }}) + - go vet {{ default .DEFAULT_TARGETS .TARGETS }} + - golint {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }} - check-fmt: - desc: Run go fmt as a test with return code + check-legacy: + desc: Check fmt and lint for the `legacy` package cmds: - - test -z $(go fmt {{ default "./..." .TARGETS }}) - - check-lint: - desc: Run linters - cmds: - - go vet {{ default "./..." .TARGETS }} - - golint {{.GOLINTFLAGS}} {{ default "./..." .TARGETS }} + - test -z $(go fmt ./legacy/...) + - go vet ./legacy/... + - golint {{.GOLINTFLAGS}} ./legacy/... vars: DEFAULT_TARGETS: "./arduino/... ./auth/... ./cli/... ./commands/... ./executils/... ./version/..." From ba053b607b6c5704df0f7a49fa52f870b08c18d0 Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 15:56:37 +0200 Subject: [PATCH 11/18] removed go lint check for legacy lint task no need to be obsessed on linting for a module that will be properly refactored out from the legacy --- Taskfile.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 1ed010e758f..91949c1d0ba 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -39,7 +39,6 @@ tasks: cmds: - test -z $(go fmt ./legacy/...) - go vet ./legacy/... - - golint {{.GOLINTFLAGS}} ./legacy/... vars: DEFAULT_TARGETS: "./arduino/... ./auth/... ./cli/... ./commands/... ./executils/... ./version/..." From 7f3ddf80b6fdd5c6253b8065bf96a85732da5abc Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 16:15:13 +0200 Subject: [PATCH 12/18] add dynamic DEFAULT_TARGET generation list --- Taskfile.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 91949c1d0ba..6e4f9d4f5d6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -41,7 +41,9 @@ tasks: - go vet ./legacy/... vars: - DEFAULT_TARGETS: "./arduino/... ./auth/... ./cli/... ./commands/... ./executils/... ./version/..." + # all modules of this project except for "legacy/..." module + DEFAULT_TARGETS: + sh: echo `go list ./... | grep -v legacy | tr '\n' ' '` # build vars VERSIONSTRING: "0.3.6-alpha.preview" From 4b464aa213850682740f5470491ad0e633c7c6ee Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 16:17:43 +0200 Subject: [PATCH 13/18] replace golangci-lint with simple go-task check --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56824ca2e94..0b16f2a6583 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,8 @@ install: - go get golang.org/x/lint/golint script: - # Check if the code is formatted - - $(exit $(go fmt ./... | wc -l)) - # Run linter - - golangci-lint run + # Check if the code is formatted and run linter + - ./bin/task check # Build and test - ./bin/task build - ./bin/task test From c361c13528eb1e90123e1b33c9567342e237e99f Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 16:24:22 +0200 Subject: [PATCH 14/18] fix upload for integ and unit test in codeconv.io --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b16f2a6583..14d34d7f1c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ script: - ./bin/task test-legacy after_success: - - bash <(curl -s https://codecov.io/bash) -cF unittests,integration + - bash <(curl -s https://codecov.io/bash) -cF unit -f '*_unit.txt' + - bash <(curl -s https://codecov.io/bash) -cF integ -f '*_integ.txt' From 1f7c45948d350ee9c06acb97c805401302b69e4d Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 16:40:54 +0200 Subject: [PATCH 15/18] raise to 10m test timeput for unit and integ tests --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 6e4f9d4f5d6..c90379b14b9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -54,7 +54,7 @@ vars: -X github.com/arduino/arduino-cli/version.commit={{.COMMIT}}' # test vars - GOFLAGS: "-timeout 5m -v -coverpkg=./... -covermode=atomic" + GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic" TEST_VERSIONSTRING: "0.0.0-test.preview" TEST_COMMIT: "deadbeef" TEST_LDFLAGS: > From 5ffe1a310c01444b2435940e7acf1b1f47e2debf Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 17:34:22 +0200 Subject: [PATCH 16/18] add task test-unit-race to specificly run unit test with rece condition detection in order to do not slow down testing too much also because we do not have particular race conditions to detect at the moment --- README.md | 6 +++++- Taskfile.yml | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e282ed85425..7e8756a278e 100644 --- a/README.md +++ b/README.md @@ -344,9 +344,13 @@ Currently Unit and Integration test are available for launch in 2 ways: ``` * build: Build the project -* test: Run the full testsuite +* check: Check fmt and lint, `legacy` will be skipped +* check-legacy: Check fmt and lint for the `legacy` package +* test: Run the full testsuite, `legacy` will be skipped * test-integration: Run integration tests only +* test-legacy: Run tests for the `legacy` package * test-unit: Run unit tests only +* test-unit-race: Run unit tests only with race condition detection ``` For Example to launch unit tests only run: `task test-unit` \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index c90379b14b9..b7ecbb9212d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,7 +15,7 @@ tasks: test-unit: desc: Run unit tests only cmds: - - go test -race -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} + - go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} test-integration: desc: Run integration tests only @@ -23,10 +23,15 @@ tasks: - go test -run Integration {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}} test-legacy: - desc: Run tests + desc: Run tests for the `legacy` package cmds: - go test {{ default "-v" .GOFLAGS }} ./legacy/... + test-unit-race: + desc: Run unit tests only with race condition detection + cmds: + - go test -short -race {{ default "-v" .GOFLAGS }} -coverprofile=coverage_race_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} + check: desc: Check fmt and lint, `legacy` will be skipped cmds: From 9116380f6109e35f8c214b94275815687e5c666a Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 17:58:41 +0200 Subject: [PATCH 17/18] clean from drone configuration and related dockerfiles --- .drone.yml | 8 -------- Dockerfiles/CI/Dockerfile | 4 ---- 2 files changed, 12 deletions(-) delete mode 100644 .drone.yml delete mode 100644 Dockerfiles/CI/Dockerfile diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index e3d9ee9b22d..00000000000 --- a/.drone.yml +++ /dev/null @@ -1,8 +0,0 @@ -kind: pipeline -name: default - -steps: -- name: test - image: arduino/arduino-cli:drone-0.0.1 - commands: - - task test \ No newline at end of file diff --git a/Dockerfiles/CI/Dockerfile b/Dockerfiles/CI/Dockerfile deleted file mode 100644 index 8110af0a949..00000000000 --- a/Dockerfiles/CI/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM golang:1.12 - -RUN set -ex \ - && curl -sL https://taskfile.dev/install.sh | sh \ No newline at end of file From bef4ab2760a7155bd5f7233ed94f1bcc5b394ee7 Mon Sep 17 00:00:00 2001 From: Roberto Sora Date: Thu, 13 Jun 2019 19:02:22 +0200 Subject: [PATCH 18/18] add missing documentation temporary comment to make linter happy this is a FIXME commit, in next months all the FIXMEDOCS placeholders must be replaced with proper documentation --- arduino/cores/packagemanager/loader.go | 4 ++- .../cores/packagemanager/package_manager.go | 10 ++++++++ arduino/libraries/libraries.go | 5 ++++ cli/cli.go | 3 +++ commands/board/attach.go | 1 + commands/board/details.go | 1 + commands/board/list.go | 1 + commands/board/listall.go | 1 + commands/compile/compile.go | 1 + commands/core/download.go | 1 + commands/core/install.go | 1 + commands/core/list.go | 1 + commands/core/search.go | 1 + commands/core/uninstall.go | 1 + commands/core/upgrade.go | 1 + commands/instances.go | 9 +++++++ commands/lib/download.go | 1 + commands/lib/install.go | 1 + commands/lib/list.go | 3 +++ commands/lib/search.go | 2 ++ commands/lib/uninstall.go | 1 + commands/lib/upgrade.go | 1 + commands/upload/upload.go | 1 + configs/navigate.go | 1 + daemon/daemon.go | 25 +++++++++++++++++++ output/table.go | 10 ++++++++ output/text.go | 14 +++++++++++ version/version.go | 2 ++ 28 files changed, 103 insertions(+), 1 deletion(-) diff --git a/arduino/cores/packagemanager/loader.go b/arduino/cores/packagemanager/loader.go index 488e6b4a9f7..0aa4ddb8185 100644 --- a/arduino/cores/packagemanager/loader.go +++ b/arduino/cores/packagemanager/loader.go @@ -27,7 +27,7 @@ import ( "github.com/arduino/arduino-cli/configs" "github.com/arduino/go-paths-helper" properties "github.com/arduino/go-properties-orderedmap" - "go.bug.st/relaxed-semver" + semver "go.bug.st/relaxed-semver" ) // LoadHardware read all plaforms from the configured paths @@ -361,6 +361,7 @@ func (pm *PackageManager) loadToolReleasesFromTool(tool *cores.Tool, toolPath *p return nil } +// LoadToolsFromBundleDirectories FIXMEDOC func (pm *PackageManager) LoadToolsFromBundleDirectories(dirs paths.PathList) error { for _, dir := range dirs { if err := pm.LoadToolsFromBundleDirectory(dir); err != nil { @@ -370,6 +371,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectories(dirs paths.PathList) er return nil } +// LoadToolsFromBundleDirectory FIXMEDOC func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) error { pm.Log.Infof("Loading tools from bundle dir: %s", toolsPath) diff --git a/arduino/cores/packagemanager/package_manager.go b/arduino/cores/packagemanager/package_manager.go index 3e50c3a3cbf..3654121d486 100644 --- a/arduino/cores/packagemanager/package_manager.go +++ b/arduino/cores/packagemanager/package_manager.go @@ -59,14 +59,17 @@ func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path) } } +// Clear FIXMEDOC func (pm *PackageManager) Clear() { pm.packages = cores.NewPackages() } +// GetPackages FIXMEDOC func (pm *PackageManager) GetPackages() *cores.Packages { return pm.packages } +// FindPlatformReleaseProvidingBoardsWithVidPid FIXMEDOC func (pm *PackageManager) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid string) []*cores.PlatformRelease { res := []*cores.PlatformRelease{} for _, targetPackage := range pm.packages.Packages { @@ -86,6 +89,7 @@ func (pm *PackageManager) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid return res } +// FindBoardsWithVidPid FIXMEDOC func (pm *PackageManager) FindBoardsWithVidPid(vid, pid string) []*cores.Board { res := []*cores.Board{} for _, targetPackage := range pm.packages.Packages { @@ -102,6 +106,7 @@ func (pm *PackageManager) FindBoardsWithVidPid(vid, pid string) []*cores.Board { return res } +// FindBoardsWithID FIXMEDOC func (pm *PackageManager) FindBoardsWithID(id string) []*cores.Board { res := []*cores.Board{} for _, targetPackage := range pm.packages.Packages { @@ -290,6 +295,7 @@ func (ta *ToolActions) IsInstalled() (bool, error) { return false, nil } +// Release FIXMEDOC func (ta *ToolActions) Release(version *semver.RelaxedVersion) *ToolReleaseActions { if ta.forwardError != nil { return &ToolReleaseActions{forwardError: ta.forwardError} @@ -310,6 +316,7 @@ type ToolReleaseActions struct { forwardError error } +// Get FIXMEDOC func (tr *ToolReleaseActions) Get() (*cores.ToolRelease, error) { if tr.forwardError != nil { return nil, tr.forwardError @@ -340,6 +347,7 @@ func (pm *PackageManager) GetInstalledPlatformRelease(platform *cores.Platform) return best } +// GetAllInstalledToolsReleases FIXMEDOC func (pm *PackageManager) GetAllInstalledToolsReleases() []*cores.ToolRelease { tools := []*cores.ToolRelease{} for _, targetPackage := range pm.packages.Packages { @@ -384,6 +392,7 @@ func (pm *PackageManager) InstalledBoards() []*cores.Board { return boards } +// FindToolsRequiredForBoard FIXMEDOC func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*cores.ToolRelease, error) { pm.Log.Infof("Searching tools required for board %s", board) @@ -421,6 +430,7 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core return requiredTools, nil } +// FindToolDependency FIXMEDOC func (pm *PackageManager) FindToolDependency(dep *cores.ToolDependency) *cores.ToolRelease { toolRelease, err := pm.Package(dep.ToolPackager).Tool(dep.ToolName).Release(dep.ToolVersion).Get() if err != nil { diff --git a/arduino/libraries/libraries.go b/arduino/libraries/libraries.go index a8799fbb1b9..b3b4ec7980c 100644 --- a/arduino/libraries/libraries.go +++ b/arduino/libraries/libraries.go @@ -26,8 +26,13 @@ import ( semver "go.bug.st/relaxed-semver" ) +// MandatoryProperties FIXMEDOC var MandatoryProperties = []string{"name", "version", "author", "maintainer"} + +// OptionalProperties FIXMEDOC var OptionalProperties = []string{"sentence", "paragraph", "url"} + +// ValidCategories FIXMEDOC var ValidCategories = map[string]bool{ "Display": true, "Communication": true, diff --git a/cli/cli.go b/cli/cli.go index 54e028e0f1b..cafc6b87a22 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -58,6 +58,7 @@ var appName = filepath.Base(os.Args[0]) // VersionInfo contains all info injected during build var VersionInfo = version.NewInfo(appName) +// HTTPClientHeader is the object that will be propagated to configure the clients inside the downloaders var HTTPClientHeader = getHTTPClientHeader() // ErrLogrus represents the logrus instance, which has the role to @@ -70,6 +71,7 @@ var GlobalFlags struct { OutputJSON bool // true output in JSON, false output as Text } +// Config FIXMEDOC var Config *configs.Configuration func packageManagerInitReq() *rpc.InitReq { @@ -96,6 +98,7 @@ func getHTTPClientHeader() http.Header { return downloaderHeaders } +// InitInstance FIXMEDOC func InitInstance() *rpc.InitResp { logrus.Info("Initializing package manager") req := packageManagerInitReq() diff --git a/commands/board/attach.go b/commands/board/attach.go index 329302070fb..bf8cb7a902c 100644 --- a/commands/board/attach.go +++ b/commands/board/attach.go @@ -34,6 +34,7 @@ import ( paths "github.com/arduino/go-paths-helper" ) +// Attach FIXMEDOC func Attach(ctx context.Context, req *rpc.BoardAttachReq, taskCB commands.TaskProgressCB) (*rpc.BoardAttachResp, error) { pm := commands.GetPackageManager(req) diff --git a/commands/board/details.go b/commands/board/details.go index 9837c8c9c55..e350687330c 100644 --- a/commands/board/details.go +++ b/commands/board/details.go @@ -27,6 +27,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// Details FIXMEDOC func Details(ctx context.Context, req *rpc.BoardDetailsReq) (*rpc.BoardDetailsResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/board/list.go b/commands/board/list.go index a4747c07210..389af5805ee 100644 --- a/commands/board/list.go +++ b/commands/board/list.go @@ -26,6 +26,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// List FIXMEDOC func List(ctx context.Context, req *rpc.BoardListReq) (*rpc.BoardListResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/board/listall.go b/commands/board/listall.go index 48343458ad5..f488ac0d3c8 100644 --- a/commands/board/listall.go +++ b/commands/board/listall.go @@ -26,6 +26,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// ListAll FIXMEDOC func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/compile/compile.go b/commands/compile/compile.go index d4635393963..bbb9eb2a607 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -40,6 +40,7 @@ import ( "github.com/sirupsen/logrus" ) +// Compile FIXMEDOC func Compile(ctx context.Context, req *rpc.CompileReq, outStream io.Writer, errStream io.Writer) (*rpc.CompileResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/core/download.go b/commands/core/download.go index 86e389b20f8..787dc0b23ad 100644 --- a/commands/core/download.go +++ b/commands/core/download.go @@ -29,6 +29,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformDownload FIXMEDOC func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, downloadCB commands.DownloadProgressCB, downloaderHeaders http.Header) (*rpc.PlatformDownloadResp, error) { pm := commands.GetPackageManager(req) diff --git a/commands/core/install.go b/commands/core/install.go index d418aafa3ec..876162aae61 100644 --- a/commands/core/install.go +++ b/commands/core/install.go @@ -29,6 +29,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformInstall FIXMEDOC func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq, downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) (*rpc.PlatformInstallResp, error) { diff --git a/commands/core/list.go b/commands/core/list.go index 75992641650..591a1819d50 100644 --- a/commands/core/list.go +++ b/commands/core/list.go @@ -25,6 +25,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformList FIXMEDOC func PlatformList(ctx context.Context, req *rpc.PlatformListReq) (*rpc.PlatformListResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/core/search.go b/commands/core/search.go index ae75738d644..80dfdda0db0 100644 --- a/commands/core/search.go +++ b/commands/core/search.go @@ -28,6 +28,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformSearch FIXMEDOC func PlatformSearch(ctx context.Context, req *rpc.PlatformSearchReq) (*rpc.PlatformSearchResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/core/uninstall.go b/commands/core/uninstall.go index 031b5eb200c..2b8b75a62fe 100644 --- a/commands/core/uninstall.go +++ b/commands/core/uninstall.go @@ -28,6 +28,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformUninstall FIXMEDOC func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq, taskCB commands.TaskProgressCB) (*rpc.PlatformUninstallResp, error) { pm := commands.GetPackageManager(req) if pm == nil { diff --git a/commands/core/upgrade.go b/commands/core/upgrade.go index 6099ccfc59e..ad430831ace 100644 --- a/commands/core/upgrade.go +++ b/commands/core/upgrade.go @@ -28,6 +28,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// PlatformUpgrade FIXMEDOC func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq, downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) (*rpc.PlatformUpgradeResp, error) { diff --git a/commands/instances.go b/commands/instances.go index e26852e1ac3..d3eb0cccffd 100644 --- a/commands/instances.go +++ b/commands/instances.go @@ -55,10 +55,12 @@ type CoreInstance struct { discoveries []*discovery.Discovery } +// InstanceContainer FIXMEDOC type InstanceContainer interface { GetInstance() *rpc.Instance } +// GetPackageManager FIXMEDOC func GetPackageManager(req InstanceContainer) *packagemanager.PackageManager { i, ok := instances[req.GetInstance().GetId()] if !ok { @@ -67,6 +69,7 @@ func GetPackageManager(req InstanceContainer) *packagemanager.PackageManager { return i.pm } +// GetLibraryManager FIXMEDOC func GetLibraryManager(req InstanceContainer) *librariesmanager.LibrariesManager { i, ok := instances[req.GetInstance().GetId()] if !ok { @@ -75,6 +78,7 @@ func GetLibraryManager(req InstanceContainer) *librariesmanager.LibrariesManager return i.lm } +// GetDiscoveries FIXMEDOC func GetDiscoveries(req InstanceContainer) []*discovery.Discovery { i, ok := instances[req.GetInstance().GetId()] if !ok { @@ -149,6 +153,7 @@ func (instance *CoreInstance) startDiscoveries() error { return nil } +// Init FIXMEDOC func Init(ctx context.Context, req *rpc.InitReq, downloadCB DownloadProgressCB, taskCB TaskProgressCB, downloaderHeaders http.Header) (*rpc.InitResp, error) { inConfig := req.GetConfiguration() if inConfig == nil { @@ -202,6 +207,7 @@ func Init(ctx context.Context, req *rpc.InitReq, downloadCB DownloadProgressCB, }, nil } +// Destroy FIXMEDOC func Destroy(ctx context.Context, req *rpc.DestroyReq) (*rpc.DestroyResp, error) { id := req.GetInstance().GetId() if _, ok := instances[id]; !ok { @@ -237,6 +243,7 @@ func UpdateLibrariesIndex(ctx context.Context, req *rpc.UpdateLibrariesIndexReq, return nil } +// UpdateIndex FIXMEDOC func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB DownloadProgressCB) (*rpc.UpdateIndexResp, error) { id := req.GetInstance().GetId() coreInstance, ok := instances[id] @@ -286,6 +293,7 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo return &rpc.UpdateIndexResp{}, nil } +// Rescan FIXMEDOC func Rescan(ctx context.Context, req *rpc.RescanReq) (*rpc.RescanResp, error) { id := req.GetInstance().GetId() coreInstance, ok := instances[id] @@ -371,6 +379,7 @@ func createInstance(ctx context.Context, config *configs.Configuration, getLibOn return pm, lm, platformIndexErrors, librariesIndexError, nil } +// Download FIXMEDOC func Download(d *downloader.Downloader, label string, downloadCB DownloadProgressCB) error { if d == nil { // This signal means that the file is already downloaded diff --git a/commands/lib/download.go b/commands/lib/download.go index a46bddd4c85..fbc24a4cc53 100644 --- a/commands/lib/download.go +++ b/commands/lib/download.go @@ -29,6 +29,7 @@ import ( "github.com/sirupsen/logrus" ) +// LibraryDownload FIXMEDOC func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadReq, downloadCB commands.DownloadProgressCB, downloaderHeaders http.Header) (*rpc.LibraryDownloadResp, error) { logrus.Info("Executing `arduino lib download`") diff --git a/commands/lib/install.go b/commands/lib/install.go index dac7d74f3eb..a9212b6b963 100644 --- a/commands/lib/install.go +++ b/commands/lib/install.go @@ -29,6 +29,7 @@ import ( "github.com/sirupsen/logrus" ) +// LibraryInstall FIXMEDOC func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallReq, downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) error { diff --git a/commands/lib/list.go b/commands/lib/list.go index b948a8d5677..b0c726b6ff3 100644 --- a/commands/lib/list.go +++ b/commands/lib/list.go @@ -32,6 +32,7 @@ type installedLib struct { Available *librariesindex.Release } +// LibraryList FIXMEDOC func LibraryList(ctx context.Context, req *rpc.LibraryListReq) (*rpc.LibraryListResp, error) { lm := commands.GetLibraryManager(req) @@ -79,6 +80,7 @@ func listLibraries(lm *librariesmanager.LibrariesManager, updatable bool, all bo return res } +// GetOutputLibrary FIXMEDOC func GetOutputLibrary(lib *libraries.Library) *rpc.Library { insdir := "" if lib.InstallDir != nil { @@ -123,6 +125,7 @@ func GetOutputLibrary(lib *libraries.Library) *rpc.Library { } } +// GetOutputRelease FIXMEDOC func GetOutputRelease(lib *librariesindex.Release) *rpc.LibraryRelease { // if lib != nil { return &rpc.LibraryRelease{ diff --git a/commands/lib/search.go b/commands/lib/search.go index eb7b1ba9abc..342ca6052e7 100644 --- a/commands/lib/search.go +++ b/commands/lib/search.go @@ -27,6 +27,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// LibrarySearch FIXMEDOC func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.LibrarySearchResp, error) { lm := commands.GetLibraryManager(req) if lm == nil { @@ -55,6 +56,7 @@ func LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.Library return &rpc.LibrarySearchResp{Libraries: res}, nil } +// GetLibraryParameters FIXMEDOC func GetLibraryParameters(rel *librariesindex.Release) *rpc.LibraryRelease { return &rpc.LibraryRelease{ Author: rel.Author, diff --git a/commands/lib/uninstall.go b/commands/lib/uninstall.go index ce864f8e535..3c23c64b200 100644 --- a/commands/lib/uninstall.go +++ b/commands/lib/uninstall.go @@ -25,6 +25,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// LibraryUninstall FIXMEDOC func LibraryUninstall(ctx context.Context, req *rpc.LibraryUninstallReq, taskCB commands.TaskProgressCB) error { lm := commands.GetLibraryManager(req) diff --git a/commands/lib/upgrade.go b/commands/lib/upgrade.go index ae0e4be1cd5..4150fb8433e 100644 --- a/commands/lib/upgrade.go +++ b/commands/lib/upgrade.go @@ -26,6 +26,7 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// LibraryUpgradeAll FIXMEDOC func LibraryUpgradeAll(ctx context.Context, req *rpc.LibraryUpgradeAllReq, downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) error { lm := commands.GetLibraryManager(req) diff --git a/commands/upload/upload.go b/commands/upload/upload.go index 1fb64da8bdc..c167ef4efd2 100644 --- a/commands/upload/upload.go +++ b/commands/upload/upload.go @@ -38,6 +38,7 @@ import ( serial "go.bug.st/serial.v1" ) +// Upload FIXMEDOC func Upload(ctx context.Context, req *rpc.UploadReq, outStream io.Writer, errStream io.Writer) (*rpc.UploadResp, error) { logrus.Info("Executing `arduino upload`") diff --git a/configs/navigate.go b/configs/navigate.go index 53f9690a549..9a4d5f5b17d 100644 --- a/configs/navigate.go +++ b/configs/navigate.go @@ -22,6 +22,7 @@ import ( "github.com/sirupsen/logrus" ) +// Navigate FIXMEDOC func (c *Configuration) Navigate(pwd *paths.Path) { parents := pwd.Clean().Parents() diff --git a/daemon/daemon.go b/daemon/daemon.go index db9e8efdac0..12a1e0ee45d 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -35,22 +35,27 @@ import ( "github.com/arduino/arduino-cli/rpc" ) +// ArduinoCoreServerImpl FIXMEDOC type ArduinoCoreServerImpl struct { DownloaderHeaders http.Header } +// BoardDetails FIXMEDOC func (s *ArduinoCoreServerImpl) BoardDetails(ctx context.Context, req *rpc.BoardDetailsReq) (*rpc.BoardDetailsResp, error) { return board.Details(ctx, req) } +// BoardList FIXMEDOC func (s *ArduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardListReq) (*rpc.BoardListResp, error) { return board.List(ctx, req) } +// BoardListAll FIXMEDOC func (s *ArduinoCoreServerImpl) BoardListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllResp, error) { return board.ListAll(ctx, req) } +// BoardAttach FIXMEDOC func (s *ArduinoCoreServerImpl) BoardAttach(req *rpc.BoardAttachReq, stream rpc.ArduinoCore_BoardAttachServer) error { resp, err := board.Attach(stream.Context(), req, @@ -62,14 +67,17 @@ func (s *ArduinoCoreServerImpl) BoardAttach(req *rpc.BoardAttachReq, stream rpc. return stream.Send(resp) } +// Destroy FIXMEDOC func (s *ArduinoCoreServerImpl) Destroy(ctx context.Context, req *rpc.DestroyReq) (*rpc.DestroyResp, error) { return commands.Destroy(ctx, req) } +// Rescan FIXMEDOC func (s *ArduinoCoreServerImpl) Rescan(ctx context.Context, req *rpc.RescanReq) (*rpc.RescanResp, error) { return commands.Rescan(ctx, req) } +// UpdateIndex FIXMEDOC func (s *ArduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexReq, stream rpc.ArduinoCore_UpdateIndexServer) error { resp, err := commands.UpdateIndex(stream.Context(), req, func(p *rpc.DownloadProgress) { stream.Send(&rpc.UpdateIndexResp{DownloadProgress: p}) }, @@ -80,6 +88,7 @@ func (s *ArduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexReq, stream rpc. return stream.Send(resp) } +// UpdateLibrariesIndex FIXMEDOC func (s *ArduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesIndexReq, stream rpc.ArduinoCore_UpdateLibrariesIndexServer) error { err := commands.UpdateLibrariesIndex(stream.Context(), req, func(p *rpc.DownloadProgress) { stream.Send(&rpc.UpdateLibrariesIndexResp{DownloadProgress: p}) }, @@ -90,6 +99,7 @@ func (s *ArduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesInd return stream.Send(&rpc.UpdateLibrariesIndexResp{}) } +// Init FIXMEDOC func (s *ArduinoCoreServerImpl) Init(req *rpc.InitReq, stream rpc.ArduinoCore_InitServer) error { resp, err := commands.Init(stream.Context(), req, func(p *rpc.DownloadProgress) { stream.Send(&rpc.InitResp{DownloadProgress: p}) }, @@ -103,10 +113,12 @@ func (s *ArduinoCoreServerImpl) Init(req *rpc.InitReq, stream rpc.ArduinoCore_In return stream.Send(resp) } +// Version FIXMEDOC func (s *ArduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionReq) (*rpc.VersionResp, error) { return &rpc.VersionResp{Version: cli.VersionInfo.VersionString}, nil } +// Compile FIXMEDOC func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoCore_CompileServer) error { resp, err := compile.Compile( stream.Context(), req, @@ -119,6 +131,7 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileReq, stream rpc.ArduinoC return stream.Send(resp) } +// PlatformInstall FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallReq, stream rpc.ArduinoCore_PlatformInstallServer) error { resp, err := core.PlatformInstall( stream.Context(), req, @@ -132,6 +145,7 @@ func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallReq, str return stream.Send(resp) } +// PlatformDownload FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReq, stream rpc.ArduinoCore_PlatformDownloadServer) error { resp, err := core.PlatformDownload( stream.Context(), req, @@ -144,6 +158,7 @@ func (s *ArduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReq, s return stream.Send(resp) } +// PlatformUninstall FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformUninstall(req *rpc.PlatformUninstallReq, stream rpc.ArduinoCore_PlatformUninstallServer) error { resp, err := core.PlatformUninstall( stream.Context(), req, @@ -155,6 +170,7 @@ func (s *ArduinoCoreServerImpl) PlatformUninstall(req *rpc.PlatformUninstallReq, return stream.Send(resp) } +// PlatformUpgrade FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeReq, stream rpc.ArduinoCore_PlatformUpgradeServer) error { resp, err := core.PlatformUpgrade( stream.Context(), req, @@ -168,14 +184,17 @@ func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeReq, str return stream.Send(resp) } +// PlatformSearch FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformSearch(ctx context.Context, req *rpc.PlatformSearchReq) (*rpc.PlatformSearchResp, error) { return core.PlatformSearch(ctx, req) } +// PlatformList FIXMEDOC func (s *ArduinoCoreServerImpl) PlatformList(ctx context.Context, req *rpc.PlatformListReq) (*rpc.PlatformListResp, error) { return core.PlatformList(ctx, req) } +// Upload FIXMEDOC func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadReq, stream rpc.ArduinoCore_UploadServer) error { resp, err := upload.Upload( stream.Context(), req, @@ -203,6 +222,7 @@ func feedStream(streamer func(data []byte)) io.Writer { return w } +// LibraryDownload FIXMEDOC func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadReq, stream rpc.ArduinoCore_LibraryDownloadServer) error { resp, err := lib.LibraryDownload( stream.Context(), req, @@ -215,6 +235,7 @@ func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadReq, str return stream.Send(resp) } +// LibraryInstall FIXMEDOC func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallReq, stream rpc.ArduinoCore_LibraryInstallServer) error { err := lib.LibraryInstall( stream.Context(), req, @@ -228,6 +249,7 @@ func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallReq, strea return stream.Send(&rpc.LibraryInstallResp{}) } +// LibraryUninstall FIXMEDOC func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallReq, stream rpc.ArduinoCore_LibraryUninstallServer) error { err := lib.LibraryUninstall(stream.Context(), req, func(p *rpc.TaskProgress) { stream.Send(&rpc.LibraryUninstallResp{TaskProgress: p}) }, @@ -238,6 +260,7 @@ func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallReq, s return stream.Send(&rpc.LibraryUninstallResp{}) } +// LibraryUpgradeAll FIXMEDOC func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllReq, stream rpc.ArduinoCore_LibraryUpgradeAllServer) error { err := lib.LibraryUpgradeAll(stream.Context(), req, func(p *rpc.DownloadProgress) { stream.Send(&rpc.LibraryUpgradeAllResp{Progress: p}) }, @@ -250,10 +273,12 @@ func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllReq, return stream.Send(&rpc.LibraryUpgradeAllResp{}) } +// LibrarySearch FIXMEDOC func (s *ArduinoCoreServerImpl) LibrarySearch(ctx context.Context, req *rpc.LibrarySearchReq) (*rpc.LibrarySearchResp, error) { return lib.LibrarySearch(ctx, req) } +// LibraryList FIXMEDOC func (s *ArduinoCoreServerImpl) LibraryList(ctx context.Context, req *rpc.LibraryListReq) (*rpc.LibraryListResp, error) { return lib.LibraryList(ctx, req) } diff --git a/output/table.go b/output/table.go index 7757e72334a..5273576126d 100644 --- a/output/table.go +++ b/output/table.go @@ -22,6 +22,7 @@ import ( "math" ) +// Table FIXMEDOC type Table struct { hasHeader bool columnsCount int @@ -29,23 +30,29 @@ type Table struct { rows []*TableRow } +// TableRow FIXMEDOC type TableRow struct { cells []TextBox } +// NewTable FIXMEDOC func NewTable() *Table { return &Table{ rows: []*TableRow{}, } } +// TableColumnWidthMode FIXMEDOC type TableColumnWidthMode int const ( + // Minimum FIXMEDOC Minimum TableColumnWidthMode = iota + // Average FIXMEDOC Average ) +// SetColumnWidthMode FIXMEDOC func (t *Table) SetColumnWidthMode(x int, mode TableColumnWidthMode) { for len(t.columnsWidthMode) <= x { t.columnsWidthMode = append(t.columnsWidthMode, Minimum) @@ -74,6 +81,7 @@ func (t *Table) makeTableRow(columns ...interface{}) *TableRow { return &TableRow{cells: cells} } +// SetHeader FIXMEDOC func (t *Table) SetHeader(columns ...interface{}) { row := t.makeTableRow(columns...) if t.hasHeader { @@ -84,11 +92,13 @@ func (t *Table) SetHeader(columns ...interface{}) { } } +// AddRow FIXMEDOC func (t *Table) AddRow(columns ...interface{}) { row := t.makeTableRow(columns...) t.rows = append(t.rows, row) } +// Render FIXMEDOC func (t *Table) Render() string { // find max width for each row average := make([]int, t.columnsCount) diff --git a/output/text.go b/output/text.go index f19753f25e3..e8151dfd701 100644 --- a/output/text.go +++ b/output/text.go @@ -31,41 +31,50 @@ var yellow = color.New(color.FgYellow).SprintfFunc() var white = color.New(color.FgWhite).SprintfFunc() var hiWhite = color.New(color.FgHiWhite).SprintfFunc() +// Red FIXMEDOC func Red(in string) *Text { return &Text{raw: red(in), clean: in} } +// Blue FIXMEDOC func Blue(in string) *Text { return &Text{raw: blue(in), clean: in} } +// Green FIXMEDOC func Green(in string) *Text { return &Text{raw: green(in), clean: in} } +// Yellow FIXMEDOC func Yellow(in string) *Text { return &Text{raw: yellow(in), clean: in} } +// White FIXMEDOC func White(in string) *Text { return &Text{raw: white(in), clean: in} } +// HiWhite FIXMEDOC func HiWhite(in string) *Text { return &Text{raw: hiWhite(in), clean: in} } +// TextBox FIXMEDOC type TextBox interface { Len() int Pad(availableWidth int) string } +// Text FIXMEDOC type Text struct { clean string raw string justify int } +// Len FIXMEDOC func (t *Text) Len() int { return utf8.RuneCountInString(t.clean) } @@ -74,18 +83,22 @@ func (t *Text) Len() int { // return t.raw // } +// JustifyLeft FIXMEDOC func (t *Text) JustifyLeft() { t.justify = 0 } +// JustifyCenter FIXMEDOC func (t *Text) JustifyCenter() { t.justify = 1 } +// JustifyRight FIXMEDOC func (t *Text) JustifyRight() { t.justify = 2 } +// Pad FIXMEDOC func (t *Text) Pad(totalLen int) string { delta := totalLen - t.Len() switch t.justify { @@ -108,6 +121,7 @@ func spaces(n int) string { return res } +// Sprintf FIXMEDOC func Sprintf(format string, args ...interface{}) TextBox { cleanArgs := make([]interface{}, len(args)) for i, arg := range args { diff --git a/version/version.go b/version/version.go index c59cc26c398..b8326b82bd3 100644 --- a/version/version.go +++ b/version/version.go @@ -29,6 +29,7 @@ var ( buildDate = time.Time{} ) +// Info FIXMEDOC type Info struct { Application string `json:"Application"` VersionString string `json:"VersionString"` @@ -36,6 +37,7 @@ type Info struct { BuildDate time.Time `json:"BuildDate"` } +// NewInfo FIXMEDOC func NewInfo(application string) *Info { return &Info{ Application: application,