Skip to content

Commit b53e33e

Browse files
committed
chore: improve doc
1 parent e5e6735 commit b53e33e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cmd/goipmi/commands/x.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func NewCmdX() *cobra.Command {
3131
}
3232
cmd.AddCommand(NewCmdXGetSDRs())
3333
cmd.AddCommand(NewCmdXGetSensors())
34+
cmd.AddCommand(NewCmdXGetSensorsFilterFans())
3435
cmd.AddCommand(NewCmdXGetDeviceSDRs())
3536
cmd.AddCommand(NewCmdXGetPayloadActivationStatus())
3637
cmd.AddCommand(NewCmdXGetDeviceGUID())
@@ -137,6 +138,24 @@ func NewCmdXGetSensors() *cobra.Command {
137138
return cmd
138139
}
139140

141+
func NewCmdXGetSensorsFilterFans() *cobra.Command {
142+
cmd := &cobra.Command{
143+
Use: "get-sensors-filter-fans",
144+
Short: "get-sensors-filter-fans",
145+
Run: func(cmd *cobra.Command, args []string) {
146+
ctx := context.Background()
147+
res, err := client.GetSensors(ctx, ipmi.SensorFilterOptionIsSensorType(ipmi.SensorTypeFan))
148+
if err != nil {
149+
fmt.Printf("GetSensors failed, err: %s", err)
150+
return
151+
}
152+
fmt.Printf("GetSensors succeeded, %d records\n", len(res))
153+
fmt.Println(ipmi.FormatSensors(true, res...))
154+
},
155+
}
156+
return cmd
157+
}
158+
140159
func NewCmdXGetDeviceSDRs() *cobra.Command {
141160
var show bool
142161

cmd_get_sensors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ func SensorFilterOptionIsSensorType(sensorTypes ...SensorType) func(sensor *Sens
3636
// passed all filter options, that means the filter options are logically ANDed.
3737
//
3838
// If you want the filter options are logically ORed, use `GetSensorsAny`
39+
//
40+
// Example:
41+
//
42+
// // get all sensors with fan type
43+
// sensors, err := client.GetSensors(ctx, ipmi.SensorFilterOptionIsSensorType(ipmi.SensorTypeFan))
3944
func (c *Client) GetSensors(ctx context.Context, filterOptions ...SensorFilterOption) ([]*Sensor, error) {
4045
var out = make([]*Sensor, 0)
4146

0 commit comments

Comments
 (0)