diff --git a/README.md b/README.md index d76964f..c8e9ac2 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Usage: quick-plan [import|schedule] [options] -m, --measurement_system "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 with a weekly based plan in CSV format diff --git a/src/main/scala/com.github.mgifos.workouts/Main.scala b/src/main/scala/com.github.mgifos.workouts/Main.scala index 1b80a5d..62fdb50 100644 --- a/src/main/scala/com.github.mgifos.workouts/Main.scala +++ b/src/main/scala/com.github.mgifos.workouts/Main.scala @@ -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) =>