Skip to content

Commit 5626f0b

Browse files
Paolo Calaopolldo
Paolo Calao
authored andcommitted
Rename fields of printed structs to snake case (#85)
Improvement to make cli feedback a bit more programmers and tools friendly. Without this change, one has to quote the name of the variables to prevent a parser to interpret '-' as an arithmetic (or whatever) minus sign.
1 parent d99df41 commit 5626f0b

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

cli/device/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (r createResult) Data() interface{} {
8080

8181
func (r createResult) String() string {
8282
return fmt.Sprintf(
83-
"name: %s\nid: %s\nboard: %s\nserial-number: %s\nfqbn: %s",
83+
"name: %s\nid: %s\nboard: %s\nserial_number: %s\nfqbn: %s",
8484
r.device.Name,
8585
r.device.ID,
8686
r.device.Board,

cli/device/creategeneric.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (r createGenericResult) Data() interface{} {
7373

7474
func (r createGenericResult) String() string {
7575
return fmt.Sprintf(
76-
"id: %s\nsecret-key: %s\nname: %s\nboard: %s\nserial-number: %s\nfqbn: %s",
76+
"id: %s\nsecret_key: %s\nname: %s\nboard: %s\nserial_number: %s\nfqbn: %s",
7777
r.device.ID,
7878
r.device.Password,
7979
r.device.Name,

cli/device/createlora.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ func (r createLoraResult) Data() interface{} {
8787

8888
func (r createLoraResult) String() string {
8989
return fmt.Sprintf(
90-
"name: %s\nid: %s\nboard: %s\nserial-number: %s\nfqbn: %s"+
91-
"\napp-eui: %s\napp-key: %s\neui: %s",
90+
"name: %s\nid: %s\nboard: %s\nserial_number: %s\nfqbn: %s"+
91+
"\napp_eui: %s\napp_key: %s\neui: %s",
9292
r.device.Name,
9393
r.device.ID,
9494
r.device.Board,

cli/thing/clone.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (r cloneResult) Data() interface{} {
7575

7676
func (r cloneResult) String() string {
7777
return fmt.Sprintf(
78-
"name: %s\nid: %s\ndevice-id: %s\nvariables: %s",
78+
"name: %s\nid: %s\ndevice_id: %s\nvariables: %s",
7979
r.thing.Name,
8080
r.thing.ID,
8181
r.thing.DeviceID,

cli/thing/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (r createResult) Data() interface{} {
8282

8383
func (r createResult) String() string {
8484
return fmt.Sprintf(
85-
"name: %s\nid: %s\ndevice-id: %s\nvariables: %s",
85+
"name: %s\nid: %s\ndevice_id: %s\nvariables: %s",
8686
r.thing.Name,
8787
r.thing.ID,
8888
r.thing.DeviceID,

command/device/creategeneric.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type CreateGenericParams struct {
3939
// parameters of a generic Arduino IoT Cloud device.
4040
type DeviceGenericInfo struct {
4141
DeviceInfo
42-
Password string `json:"secret-key"`
42+
Password string `json:"secret_key"`
4343
}
4444

4545
// CreateGeneric command is used to add a new generic device to Arduino IoT Cloud.

command/device/createlora.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const (
4848
// parameters of an Arduino IoT Cloud LoRa device.
4949
type DeviceLoraInfo struct {
5050
DeviceInfo
51-
AppEUI string `json:"app-eui"`
52-
AppKey string `json:"app-key"`
51+
AppEUI string `json:"app_eui"`
52+
AppKey string `json:"app_key"`
5353
EUI string `json:"eui"`
5454
}
5555

command/device/device.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type DeviceInfo struct {
2828
Name string `json:"name"`
2929
ID string `json:"id"`
3030
Board string `json:"board"`
31-
Serial string `json:"serial-number"`
31+
Serial string `json:"serial_number"`
3232
FQBN string `json:"fqbn"`
3333
Tags []string `json:"tags,omitempty"`
3434
}

command/thing/thing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
type ThingInfo struct {
2828
Name string `json:"name"`
2929
ID string `json:"id"`
30-
DeviceID string `json:"device-id"`
30+
DeviceID string `json:"device_id"`
3131
Variables []string `json:"variables"`
3232
Tags []string `json:"tags,omitempty"`
3333
}

0 commit comments

Comments
 (0)