diff --git a/cmd/flags.go b/cmd/flags.go index 0436d4be9..790d5d985 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -38,6 +38,9 @@ const ( flagStop = "stop" flagStopDescription = "Stop charging" + flagRepeat = "repeat" + flagRepeatDescription = "Repeat until interrupted" + flagDigits = "digits" flagDelay = "delay" flagForce = "force" diff --git a/cmd/meter.go b/cmd/meter.go index babb2a12a..d0ea6713c 100644 --- a/cmd/meter.go +++ b/cmd/meter.go @@ -20,6 +20,7 @@ func init() { rootCmd.AddCommand(meterCmd) meterCmd.Flags().StringP(flagBatteryMode, "b", "", flagBatteryModeDescription) meterCmd.Flags().DurationP(flagBatteryModeWait, "w", 0, flagBatteryModeWaitDescription) + meterCmd.Flags().BoolP(flagRepeat, "r", false, flagRepeatDescription) } func runMeter(cmd *cobra.Command, args []string) { @@ -68,11 +69,15 @@ func runMeter(cmd *cobra.Command, args []string) { if !flagUsed { d := dumper{len: len(meters)} + REPEAT: for _, dev := range meters { v := dev.Instance() d.DumpWithHeader(dev.Config().Name, v) } + if ok, _ := cmd.Flags().GetBool(flagRepeat); ok { + goto REPEAT + } } // wait for shutdown