fix: renamed packages
This commit is contained in:
@ -1,24 +1,49 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/sensor"
|
||||
temperatureSensor "git.cryptic.systems/fh-trier/go-flucky/pkg/sensor/temperature"
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var sensorType string
|
||||
|
||||
var addTemperatureSensorCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Short: "Add Temperature Sensor",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := sensor.AddTemperature(args[0], sensorName, configDir, wirePath); err != nil {
|
||||
t, err := matchSensorTyp(sensorType)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// DS18B20
|
||||
if t == types.SENSOR_DS18B20 {
|
||||
if err := temperatureSensor.AddDS18B20(args[0], sensorName, configDir, wirePath); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
temperatureSensorCmd.AddCommand(addTemperatureSensorCmd)
|
||||
addTemperatureSensorCmd.Flags().StringVarP(&sensorType, "type", "t", "DS18B20", "Sensor Types: DS18B20, DHT11")
|
||||
}
|
||||
|
||||
func matchSensorTyp(sensorType string) (types.SensorType, error) {
|
||||
|
||||
switch sensorType {
|
||||
case "DS18B20":
|
||||
return types.SENSOR_DS18B20, nil
|
||||
case "DHT11":
|
||||
return types.SENSOR_DHT11, nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("Can not match %v with a sensor type", sensorType)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/sensor"
|
||||
temperatureSensor "git.cryptic.systems/fh-trier/go-flucky/pkg/sensor/temperature"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -15,7 +15,7 @@ var listTemperatureSensorCmd = &cobra.Command{
|
||||
Short: "List Temperature Sensors",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := sensor.PrintTemperature(os.Stdout, configDir, quiet); err != nil {
|
||||
if err := temperatureSensor.Print(os.Stdout, configDir, quiet); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
|
@ -3,7 +3,7 @@ package temperature
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/sensor"
|
||||
temperatureSensor "git.cryptic.systems/fh-trier/go-flucky/pkg/sensor/temperature"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -13,7 +13,7 @@ var rmTemperatureSensorCmd = &cobra.Command{
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := sensor.RemoveTemperature(args[0], configDir); err != nil {
|
||||
if err := temperatureSensor.Remove(args[0], configDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user