Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
11d9e6e3
Commit
11d9e6e3
authored
May 24, 2019
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented Version grpc command
parent
b951097a
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
217 additions
and
115 deletions
+217
-115
cli/root/root.go
cli/root/root.go
+2
-2
cli/version/version.go
cli/version/version.go
+13
-8
common/formatter/output/lib_structs.go
common/formatter/output/lib_structs.go
+0
-30
daemon/client/client.go
daemon/client/client.go
+9
-0
daemon/daemon.go
daemon/daemon.go
+5
-0
rpc/commands.pb.go
rpc/commands.pb.go
+180
-75
rpc/commands.proto
rpc/commands.proto
+8
-0
No files found.
cli/root/root.go
View file @
11d9e6e3
...
...
@@ -32,7 +32,7 @@ import (
"github.com/arduino/arduino-cli/commands/config"
"github.com/arduino/arduino-cli/commands/generatedocs"
"github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/c
ommands
/version"
"github.com/arduino/arduino-cli/c
li
/version"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/configs"
paths
"github.com/arduino/go-paths-helper"
...
...
@@ -42,7 +42,7 @@ import (
"golang.org/x/crypto/ssh/terminal"
)
// Init prepares the cobra root command.
// Init prepares the cobra root command.
func
Init
()
*
cobra
.
Command
{
command
:=
&
cobra
.
Command
{
Use
:
"arduino-cli"
,
...
...
c
ommands
/version/version.go
→
c
li
/version/version.go
View file @
11d9e6e3
...
...
@@ -18,10 +18,9 @@
package
version
import
(
"fmt"
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/common/formatter"
"github.com/arduino/arduino-cli/common/formatter/output"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
...
...
@@ -38,11 +37,17 @@ func InitCommand() *cobra.Command {
return
versionCommand
}
type
versionOutput
struct
{
Command
string
`json:"command"`
Version
string
`json:"version"`
}
func
run
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
logrus
.
Info
(
"Calling version command on `arduino`"
)
versionInfo
:=
output
.
VersionResult
{
CommandName
:
cmd
.
Parent
()
.
Name
(),
Version
:
cli
.
Version
,
res
:=
&
versionOutput
{
Command
:
cmd
.
Parent
()
.
Name
(),
Version
:
cli
.
Version
,
}
if
cli
.
OutputJSONOrElse
(
res
)
{
fmt
.
Printf
(
"%s version %s
\n
"
,
res
.
Command
,
res
.
Version
)
}
formatter
.
Print
(
versionInfo
)
}
common/formatter/output/lib_structs.go
deleted
100644 → 0
View file @
b951097a
/*
* This file is part of arduino-cli.
*
* Copyright 2018 ARDUINO SA (http://www.arduino.cc/)
*
* This software is released under the GNU General Public License version 3,
* which covers the main part of arduino-cli.
* The terms of this license can be found at:
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* You can be released from the requirements of the above licenses by purchasing
* a commercial license. Buying such a license is mandatory if you want to modify or
* otherwise use the software for commercial activities involving the Arduino
* software without disclosing the source code of your own applications. To purchase
* a commercial license, send an email to license@arduino.cc.
*/
package
output
import
"fmt"
// VersionResult represents the output of the version commands.
type
VersionResult
struct
{
CommandName
string
`json:"command,required"`
Version
string
`json:"version,required"`
}
func
(
vr
VersionResult
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s version %s"
,
vr
.
CommandName
,
vr
.
Version
)
}
daemon/client/client.go
View file @
11d9e6e3
...
...
@@ -44,6 +44,15 @@ func main() {
client
:=
rpc
.
NewArduinoCoreClient
(
conn
)
fmt
.
Println
()
// VERSION
fmt
.
Println
(
"=== calling Version"
)
versionResp
,
err
:=
client
.
Version
(
context
.
Background
(),
&
rpc
.
VersionReq
{})
if
err
!=
nil
{
fmt
.
Printf
(
"Error getting version: %s
\n
"
,
err
)
os
.
Exit
(
1
)
}
fmt
.
Printf
(
"---> %+v
\n\v
"
,
versionResp
)
// INIT
fmt
.
Println
(
"=== calling Init"
)
initRespStream
,
err
:=
client
.
Init
(
context
.
Background
(),
&
rpc
.
InitReq
{
...
...
daemon/daemon.go
View file @
11d9e6e3
...
...
@@ -26,6 +26,7 @@ import (
"log"
"net"
"github.com/arduino/arduino-cli/cli"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/commands/compile"
...
...
@@ -119,6 +120,10 @@ func (s *ArduinoCoreServerImpl) Init(req *rpc.InitReq, stream rpc.ArduinoCore_In
return
stream
.
Send
(
resp
)
}
func
(
s
*
ArduinoCoreServerImpl
)
Version
(
ctx
context
.
Context
,
req
*
rpc
.
VersionReq
)
(
*
rpc
.
VersionResp
,
error
)
{
return
&
rpc
.
VersionResp
{
Version
:
cli
.
Version
},
nil
}
func
(
s
*
ArduinoCoreServerImpl
)
Compile
(
req
*
rpc
.
CompileReq
,
stream
rpc
.
ArduinoCore_CompileServer
)
error
{
resp
,
err
:=
compile
.
Compile
(
stream
.
Context
(),
req
,
...
...
rpc/commands.pb.go
View file @
11d9e6e3
This diff is collapsed.
Click to expand it.
rpc/commands.proto
View file @
11d9e6e3
...
...
@@ -48,6 +48,8 @@ service ArduinoCore {
// Update libraries index
rpc
UpdateLibrariesIndex
(
UpdateLibrariesIndexReq
)
returns
(
stream
UpdateLibrariesIndexResp
)
{}
rpc
Version
(
VersionReq
)
returns
(
VersionResp
)
{}
// BOARD COMMANDS
// --------------
...
...
@@ -148,3 +150,9 @@ message UpdateLibrariesIndexReq {
message
UpdateLibrariesIndexResp
{
DownloadProgress
download_progress
=
1
;
}
message
VersionReq
{}
message
VersionResp
{
string
version
=
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment