Cli: add meter --repeat flag
This commit is contained in:
parent
e1c027c781
commit
a945013cdd
2 changed files with 8 additions and 0 deletions
|
|
@ -38,6 +38,9 @@ const (
|
|||
flagStop = "stop"
|
||||
flagStopDescription = "Stop charging"
|
||||
|
||||
flagRepeat = "repeat"
|
||||
flagRepeatDescription = "Repeat until interrupted"
|
||||
|
||||
flagDigits = "digits"
|
||||
flagDelay = "delay"
|
||||
flagForce = "force"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue