chore: add timeout to charger, vehicle, dump (#24168)
This commit is contained in:
parent
6d5b0a5ab5
commit
f8b6c367de
3 changed files with 11 additions and 3 deletions
|
|
@ -29,6 +29,7 @@ func init() {
|
|||
chargerCmd.Flags().BoolP(flagWakeup, "w", false, flagWakeupDescription)
|
||||
chargerCmd.Flags().IntP(flagPhases, "p", 0, flagPhasesDescription)
|
||||
chargerCmd.Flags().Bool(flagHeartbeat, false, flagHeartbeatDescription)
|
||||
chargerCmd.Flags().Duration(flagTimeout, time.Second, flagTimeoutDescription)
|
||||
}
|
||||
|
||||
func runCharger(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -125,7 +126,8 @@ func runCharger(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
if !flagUsed {
|
||||
d := dumper{len: len(chargers)}
|
||||
timeout, _ := cmd.Flags().GetDuration(flagTimeout)
|
||||
d := dumper{len: len(chargers), timeout: timeout}
|
||||
flag := cmd.Flag(flagDiagnose).Changed
|
||||
|
||||
for _, dev := range chargers {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
"github.com/evcc-io/evcc/core"
|
||||
|
|
@ -33,6 +34,7 @@ func init() {
|
|||
rootCmd.AddCommand(dumpCmd)
|
||||
|
||||
dumpConfig = dumpCmd.Flags().Bool("cfg", false, "Dump config file")
|
||||
dumpCmd.Flags().Duration(flagTimeout, time.Second, flagTimeoutDescription)
|
||||
}
|
||||
|
||||
func handle[T any](name string, h config.Handler[T]) config.Device[T] {
|
||||
|
|
@ -90,7 +92,8 @@ func runDump(cmd *cobra.Command, args []string) {
|
|||
log.FATAL.Fatal(err)
|
||||
}
|
||||
|
||||
d := dumper{len: 2}
|
||||
timeout, _ := cmd.Flags().GetDuration(flagTimeout)
|
||||
d := dumper{len: 2, timeout: timeout}
|
||||
|
||||
d.Header("config", "=")
|
||||
fmt.Println("")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util/config"
|
||||
|
|
@ -25,6 +26,7 @@ func init() {
|
|||
vehicleCmd.Flags().BoolP(flagWakeup, "w", false, flagWakeupDescription)
|
||||
vehicleCmd.Flags().Bool(flagDiagnose, false, flagDiagnoseDescription)
|
||||
vehicleCmd.Flags().Bool(flagCloud, false, flagCloudDescription)
|
||||
vehicleCmd.Flags().Duration(flagTimeout, time.Second, flagTimeoutDescription)
|
||||
}
|
||||
|
||||
func runVehicle(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -112,7 +114,8 @@ func runVehicle(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
if !flagUsed {
|
||||
d := dumper{len: len(vehicles)}
|
||||
timeout, _ := cmd.Flags().GetDuration(flagTimeout)
|
||||
d := dumper{len: len(vehicles), timeout: timeout}
|
||||
flag := cmd.Flag(flagDiagnose).Changed
|
||||
|
||||
for _, dev := range vehicles {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue