Skip to content

Commit

Permalink
[skip changelog] gRPC "client_example" refresh (arduino#434)
Browse files Browse the repository at this point in the history
* bump go version in client go.mod

* fix help strings

* differentiate dataDir folders
  • Loading branch information
Roberto Sora authored Oct 3, 2019
1 parent cc73753 commit 39530c0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func createCliCommandTree(cmd *cobra.Command) {
cmd.AddCommand(version.NewCommand())

cmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Print the logs on the standard output.")
cmd.PersistentFlags().StringVar(&globals.LogLevel, "log-level", defaultLogLevel, "Messages with this level and above will be logged (default: warn).")
cmd.PersistentFlags().StringVar(&globals.LogLevel, "log-level", defaultLogLevel, "Messages with this level and above will be logged.")
cmd.PersistentFlags().StringVar(&logFile, "log-file", "", "Path to the file where logs will be written.")
cmd.PersistentFlags().StringVar(&logFormat, "log-format", "text", "The output format for the logs, can be [text|json].")
cmd.PersistentFlags().StringVar(&globals.OutputFormat, "format", "text", "The output format, can be [text|json].")
Expand Down
2 changes: 1 addition & 1 deletion cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "daemon",
Short: "Run as a daemon",
Short: fmt.Sprintf("Run as a daemon on port %s", port),
Long: "Running as a daemon the initialization of cores and libraries is done only once.",
Example: " " + os.Args[0] + " daemon",
Args: cobra.NoArgs,
Expand Down
2 changes: 1 addition & 1 deletion client_example/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/arduino/arduino-cli/client_example

go 1.12
go 1.13

require (
github.com/arduino/arduino-cli v0.0.0-20190826141027-35722fda467d
Expand Down
13 changes: 9 additions & 4 deletions client_example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func initInstance(client rpc.ArduinoCoreClient) *rpc.Instance {
// the data folder.
initRespStream, err := client.Init(context.Background(), &rpc.InitReq{
Configuration: &rpc.Configuration{
DataDir: dataDir,
DataDir: dataDir,
SketchbookDir: filepath.Join(dataDir, "sketchbook"),
DownloadsDir: filepath.Join(dataDir, "staging"),
},
})
if err != nil {
Expand Down Expand Up @@ -368,11 +370,12 @@ func callBoardsDetails(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
}

func callBoardAttach(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
currDir, _ := os.Getwd()
boardattachresp, err := client.BoardAttach(context.Background(),
&rpc.BoardAttachReq{
Instance: instance,
BoardUri: "/dev/ttyACM0",
SketchPath: filepath.Join(dataDir, "hello.ino"),
SketchPath: filepath.Join(currDir, "hello.ino"),
})

if err != nil {
Expand Down Expand Up @@ -402,11 +405,12 @@ func callBoardAttach(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
}

func callCompile(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
currDir, _ := os.Getwd()
compRespStream, err := client.Compile(context.Background(),
&rpc.CompileReq{
Instance: instance,
Fqbn: "arduino:samd:mkr1000",
SketchPath: "hello.ino",
SketchPath: filepath.Join(currDir, "hello.ino"),
Verbose: true,
})

Expand Down Expand Up @@ -440,11 +444,12 @@ func callCompile(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
}

func callUpload(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
currDir, _ := os.Getwd()
uplRespStream, err := client.Upload(context.Background(),
&rpc.UploadReq{
Instance: instance,
Fqbn: "arduino:samd:mkr1000",
SketchPath: "hello.ino",
SketchPath: filepath.Join(currDir, "hello.ino"),
Port: "/dev/ttyACM0",
Verbose: true,
})
Expand Down

0 comments on commit 39530c0

Please sign in to comment.