Trainerflow Docs trainerflow.com
Core elements › Group

Core elements

Group

A named, parameterized collection of commands that gives a program structure — a warm-up, a day, a week.

A Group is one of the core elements of the Coach language and it is similar to an exec. It is a named and parameterized collection of commands that, when called, runs those commands.

Groups are typically used to give a program structure. You can create a warmup group that collects all the execs of a warm-up before the main work, a day_a group for a whole training day, or a january group for all the training of January (in a year-round programming scenario).

Definition

To define a group you need the keyword group, a name, a list of parameters in parentheses (which may be empty) and a body in curly braces. The name has the usual naming limitations and the Trainerflow convention is to use a lowercase (snake_case) name for groups.

import "coach/common/rest.cl"

action BackSquat [title: "Back squat"]
action BenchPress [title: "Bench press"]
output:number reps [title: "Reps"]
output:|kg| weight [title: "Weight"]

exec squat(load) {
    specify:BackSquat reps 5, weight load
}

exec bench(load) {
    specify:BenchPress reps 5, weight load
}

group workout(squat_load, bench_load) {
    repeat 3 { squat(squat_load) }
    repeat 3 { bench(bench_load) }
}

group week(n) {
    workout(100|kg| + n * 2.5|kg|, 70|kg|)
    rest(2|day|)
    workout(100|kg| + n * 2.5|kg|, 70|kg|)
    rest(5|day|)
}

repeat n:4 { week(n) }

Calling a group

Calling a group runs its commands one by one. Unlike an exec, a group does not halt by itself: the athlete only sees the execs it calls, each one on its own screen. Groups can call execs and other groups, so a program typically reads from the top down: a program of weeks, a week of days, a day of exercises and an exercise of sets.

Parameters

As with an exec, a group can have any number of parameters, and you call it with their values. Read more here.

Measuring at the end

A group can measure inputs too. The athlete is asked for them in one extra screen, after everything else in the group is done, which is handy for a question about the whole workout:

action BackSquat [title: "Back squat"]
output:number reps [title: "Reps"]
input:number session_rpe [title: "How hard was the session?"]

exec squat() {
    specify:BackSquat reps 5
}

group workout() {
    repeat 3 { squat() }
    measure session_rpe
}

let session = workout()

Just like an exec, the group then returns those measurements, so session.session_rpe is the athlete’s answer.

Metadata

A group can set metadata just like an exec, and the mobile app reads the same two keys:

Key What it does
@title The name at the top of the athlete’s screen while they are in an exec of this group that is hidden or has no title of its own. Without it, the group’s own name is shown, e.g. workout_a.
@hidden When true, the group is passed over too, and the screen is named after the next group out. When nothing on the way is visible, the screen reads Active Program.
import "coach/strength/squat.cl"

group workout_a() {
    @title = "Workout A"
    squat([weight: 60|kg|, reps: 5], [reps: true], [])
}

workout_a()

The standard library’s exercises are hidden unless you pass them a location option, so while the athlete squats the top of their screen reads Workout A.

What goes inside

A group can hold everything you can write at the top level of a file: element definitions, variables, calls to execs and groups, ask, if, repeat and while. The one command that does not belong in a group is specify: specifications live in execs.