Add automatically cooldown: lap-button as an additional step of each workout #40

master
mgifos 7 years ago
parent 30f8479ff6
commit 5b1af42ba7
  1. 1
      README.md
  2. 12
      src/main/scala/com.github.mgifos.workouts/Main.scala

@ -48,6 +48,7 @@ Usage: quick-plan [import|schedule] [options] <file>
-m, --measurement_system <value>
"metric" (default) or "imperial" (miles, inches, ...) measurement system choice.
-x, --delete Delete all existing workouts with same names as the ones that are going to be imported.
-c, --auto-cooldown Add automatically cooldown: lap-button as an additional last step of each workout definition.
--help prints this usage text
<file> File with a weekly based plan in CSV format

@ -24,6 +24,7 @@ case class Config(mode: Option[Modes.Mode] = None,
system: MeasurementSystems.MeasurementSystem = MeasurementSystems.metric,
csv: String = "",
delete: Boolean = false,
autoCooldown: Boolean = false,
email: String = "",
password: String = "",
start: LocalDate = LocalDate.MIN,
@ -67,6 +68,10 @@ object Main extends App {
.text("Delete all existing workouts with same names as the ones contained within the file. In case of import/schedule commands, " +
"this will be done before the actual action.")
opt[Unit]('c', "auto-cooldown")
.action((_, c) => c.copy(autoCooldown = true))
.text("Add automatically cooldown: lap-button as an additional last step of each workout definition.")
help("help").text("prints this usage text")
note("")
@ -185,7 +190,12 @@ object Main extends App {
Future.successful(None)
}
val workouts = plan.workouts.toIndexedSeq
def transformWorkouts(workouts: Seq[WorkoutDef]): Seq[WorkoutDef] = {
if (config.autoCooldown) workouts.map(w => w.copy(steps = w.steps :+ CooldownStep(LapButtonPressed)))
else workouts
}
val workouts = transformWorkouts(plan.workouts.toIndexedSeq)
garmin.login().flatMap {
case Right(s) =>

Loading…
Cancel
Save