From 07733ed6991a36863090ffa5bd324a4c12d17bfa Mon Sep 17 00:00:00 2001 From: Paolo Calao Date: Fri, 17 Sep 2021 17:32:06 +0200 Subject: [PATCH] Improve struct comments --- command/config/init.go | 9 +++------ command/device/create.go | 9 +++------ command/thing/bind.go | 6 ++---- command/thing/clone.go | 6 ++---- command/thing/create.go | 6 ++---- command/thing/extract.go | 8 +++----- command/thing/list.go | 9 +++------ internal/config/config.go | 6 ++---- 8 files changed, 20 insertions(+), 39 deletions(-) diff --git a/command/config/init.go b/command/config/init.go index 46123cfd..4f53fb40 100644 --- a/command/config/init.go +++ b/command/config/init.go @@ -11,13 +11,10 @@ import ( ) // InitParams contains the parameters needed to initialize a configuration file. -// DestDir - destination directory in which the configuration file will be saved. -// Overwrite - specify if existing config file should be overwritten. -// Format - the config file format, can be 'json' or 'yaml'. type InitParams struct { - DestDir string - Overwrite bool - Format string + DestDir string // Destination directory in which the configuration file will be saved + Overwrite bool // Overwrite specifies if existing config file should be overwritten + Format string // Config file format, can be 'json' or 'yaml' } func validateFormatString(arg string) error { diff --git a/command/device/create.go b/command/device/create.go index 0a6dce21..defb567f 100644 --- a/command/device/create.go +++ b/command/device/create.go @@ -14,13 +14,10 @@ import ( // CreateParams contains the parameters needed // to find the device to be provisioned. -// Name - mandatory parameter. -// Port - optional parameter. If omitted then each serial port is analyzed. -// Fqbn - optional parameter. If omitted then the first device found gets selected. type CreateParams struct { - Name string - Port *string - Fqbn *string + Name string // Device name + Port *string // Serial port - Optional - If omitted then each serial port is analyzed + Fqbn *string // Board FQBN - Optional - If omitted then the first device found gets selected } type board struct { diff --git a/command/thing/bind.go b/command/thing/bind.go index af5854f4..d96f88e8 100644 --- a/command/thing/bind.go +++ b/command/thing/bind.go @@ -8,11 +8,9 @@ import ( // BindParams contains the parameters needed to // bind a thing to a device. -// ID indicates the thing to bind. -// deviceID indicates the device bind. type BindParams struct { - ID string - DeviceID string + ID string // ID of the thing to be bound + DeviceID string // ID of the device to be bound } // Bind command is used to bind a thing to a device diff --git a/command/thing/clone.go b/command/thing/clone.go index abac6046..bfad8a19 100644 --- a/command/thing/clone.go +++ b/command/thing/clone.go @@ -10,10 +10,8 @@ import ( // CloneParams contains the parameters needed to clone a thing. type CloneParams struct { - // Mandatory - contains the name of the thing - Name string - // Mandatory - specifies ID of thing to be cloned - CloneID string + Name string // Name of the new thing + CloneID string // ID of thing to be cloned } // Clone allows to create a new thing from an already existing one diff --git a/command/thing/create.go b/command/thing/create.go index abd9335a..641599bf 100644 --- a/command/thing/create.go +++ b/command/thing/create.go @@ -15,10 +15,8 @@ import ( // CreateParams contains the parameters needed to create a new thing. type CreateParams struct { - // Optional - contains the name of the thing - Name *string - // Mandatory - contains the path of the template file - Template string + Name *string // Name of the new thing + Template string // Path of the template file } // Create allows to create a new thing diff --git a/command/thing/extract.go b/command/thing/extract.go index a01b1a37..697ddc4e 100644 --- a/command/thing/extract.go +++ b/command/thing/extract.go @@ -15,13 +15,11 @@ import ( ) // ExtractParams contains the parameters needed to -// extract a thing from Arduino IoT Cloud and save it on local storage. -// Format determines the file format of the template ("json" or "yaml") -// Output indicates the destination path of the extraction. +// extract a template thing from Arduino IoT Cloud and save it on local storage. type ExtractParams struct { ID string - Format string - Outfile *string + Format string // Format determines the file format of the template ("json" or "yaml") + Outfile *string // Destination path of the extracted template } // Extract command is used to extract a thing template diff --git a/command/thing/list.go b/command/thing/list.go index c89639be..96d1edfa 100644 --- a/command/thing/list.go +++ b/command/thing/list.go @@ -7,13 +7,10 @@ import ( // ListParams contains the optional parameters needed // to filter the things to be listed. -// If IDs is valid, only things belonging to that list are listed. -// If DeviceID is provided, only things associated to that device are listed. -// If Variables is true, variables names are retrieved. type ListParams struct { - IDs []string - DeviceID *string - Variables bool + IDs []string // If IDs is not nil, only things belonging to that list are returned + DeviceID *string // If DeviceID is provided, only the thing associated to that device is listed. + Variables bool // If Variables is true, variable names are retrieved. } // List command is used to list diff --git a/internal/config/config.go b/internal/config/config.go index ed3ee5d1..5a55f954 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,10 +9,8 @@ import ( // Config contains all the configuration parameters // known by iot-cloud-cli type Config struct { - // Client ID of the user - Client string `map-structure:"client"` - // Secret ID of the user, unique for each Client ID - Secret string `map-structure:"secret"` + Client string `map-structure:"client"` // Client ID of the user + Secret string `map-structure:"secret"` // Secret ID of the user, unique for each Client ID } // Retrieve returns the actual parameters contained in the