@nickchristensen/cliftin 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -16
- package/dist/commands/programs/show.d.ts +1 -4
- package/dist/commands/programs/show.js +7 -16
- package/dist/commands/workouts/show.d.ts +1 -1
- package/dist/commands/workouts/show.js +12 -5
- package/dist/lib/repositories/programs.js +1 -1
- package/dist/lib/repositories/workouts.js +6 -1
- package/oclif.manifest.json +4 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ USAGE
|
|
|
47
47
|
* [`cliftin programs list`](#cliftin-programs-list)
|
|
48
48
|
* [`cliftin programs show [SELECTOR]`](#cliftin-programs-show-selector)
|
|
49
49
|
* [`cliftin workouts list`](#cliftin-workouts-list)
|
|
50
|
-
* [`cliftin workouts show WORKOUTID`](#cliftin-workouts-show-workoutid)
|
|
50
|
+
* [`cliftin workouts show [WORKOUTID]`](#cliftin-workouts-show-workoutid)
|
|
51
51
|
|
|
52
52
|
## `cliftin exercises list`
|
|
53
53
|
|
|
@@ -72,7 +72,7 @@ DESCRIPTION
|
|
|
72
72
|
List exercises
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
_See code: [src/commands/exercises/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
75
|
+
_See code: [src/commands/exercises/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/exercises/list.ts)_
|
|
76
76
|
|
|
77
77
|
## `cliftin exercises show SELECTOR`
|
|
78
78
|
|
|
@@ -106,7 +106,7 @@ DESCRIPTION
|
|
|
106
106
|
Show one exercise detail and history
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
_See code: [src/commands/exercises/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
109
|
+
_See code: [src/commands/exercises/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/exercises/show.ts)_
|
|
110
110
|
|
|
111
111
|
## `cliftin help [COMMAND]`
|
|
112
112
|
|
|
@@ -143,7 +143,7 @@ DESCRIPTION
|
|
|
143
143
|
List programs
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
_See code: [src/commands/programs/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
146
|
+
_See code: [src/commands/programs/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/programs/list.ts)_
|
|
147
147
|
|
|
148
148
|
## `cliftin programs show [SELECTOR]`
|
|
149
149
|
|
|
@@ -151,14 +151,10 @@ Show one program hierarchy
|
|
|
151
151
|
|
|
152
152
|
```
|
|
153
153
|
USAGE
|
|
154
|
-
$ cliftin programs show [SELECTOR] [--json]
|
|
154
|
+
$ cliftin programs show [SELECTOR] [--json]
|
|
155
155
|
|
|
156
156
|
ARGUMENTS
|
|
157
|
-
[SELECTOR] program id or name
|
|
158
|
-
|
|
159
|
-
FLAGS
|
|
160
|
-
--active Show active program detail
|
|
161
|
-
--current Alias for --active
|
|
157
|
+
[SELECTOR] program id or name (default: active program)
|
|
162
158
|
|
|
163
159
|
GLOBAL FLAGS
|
|
164
160
|
--json Format output as json.
|
|
@@ -167,7 +163,7 @@ DESCRIPTION
|
|
|
167
163
|
Show one program hierarchy
|
|
168
164
|
```
|
|
169
165
|
|
|
170
|
-
_See code: [src/commands/programs/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
166
|
+
_See code: [src/commands/programs/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/programs/show.ts)_
|
|
171
167
|
|
|
172
168
|
## `cliftin workouts list`
|
|
173
169
|
|
|
@@ -194,18 +190,18 @@ DESCRIPTION
|
|
|
194
190
|
List workouts
|
|
195
191
|
```
|
|
196
192
|
|
|
197
|
-
_See code: [src/commands/workouts/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
193
|
+
_See code: [src/commands/workouts/list.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/workouts/list.ts)_
|
|
198
194
|
|
|
199
|
-
## `cliftin workouts show WORKOUTID`
|
|
195
|
+
## `cliftin workouts show [WORKOUTID]`
|
|
200
196
|
|
|
201
197
|
Show one workout with exercises and sets
|
|
202
198
|
|
|
203
199
|
```
|
|
204
200
|
USAGE
|
|
205
|
-
$ cliftin workouts show WORKOUTID [--json]
|
|
201
|
+
$ cliftin workouts show [WORKOUTID] [--json]
|
|
206
202
|
|
|
207
203
|
ARGUMENTS
|
|
208
|
-
WORKOUTID workout id
|
|
204
|
+
[WORKOUTID] workout id (default: latest workout)
|
|
209
205
|
|
|
210
206
|
GLOBAL FLAGS
|
|
211
207
|
--json Format output as json.
|
|
@@ -214,5 +210,5 @@ DESCRIPTION
|
|
|
214
210
|
Show one workout with exercises and sets
|
|
215
211
|
```
|
|
216
212
|
|
|
217
|
-
_See code: [src/commands/workouts/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.
|
|
213
|
+
_See code: [src/commands/workouts/show.ts](https://github.com/nickchristensen/cliftin/blob/v1.2.0/src/commands/workouts/show.ts)_
|
|
218
214
|
<!-- commandsstop -->
|
|
@@ -5,9 +5,6 @@ export default class ProgramsShow extends Command {
|
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static enableJsonFlag: boolean;
|
|
8
|
-
static flags: {
|
|
9
|
-
active: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
current: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
};
|
|
8
|
+
static flags: {};
|
|
12
9
|
run(): Promise<unknown | void>;
|
|
13
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Args, Command
|
|
1
|
+
import { Args, Command } from '@oclif/core';
|
|
2
2
|
import { closeDb, openDb } from '../../lib/db.js';
|
|
3
3
|
import { serializeProgramDetailWithWeightUnits } from '../../lib/json-weight.js';
|
|
4
4
|
import { renderTable } from '../../lib/output.js';
|
|
@@ -30,26 +30,16 @@ function buildProgramRows(weeks, unitLabel) {
|
|
|
30
30
|
}
|
|
31
31
|
export default class ProgramsShow extends Command {
|
|
32
32
|
static args = {
|
|
33
|
-
selector: Args.string({ description: 'program id or name', ignoreStdin: true, required: false }),
|
|
33
|
+
selector: Args.string({ description: 'program id or name (default: active program)', ignoreStdin: true, required: false }),
|
|
34
34
|
};
|
|
35
35
|
static description = 'Show one program hierarchy';
|
|
36
36
|
static enableJsonFlag = true;
|
|
37
|
-
static flags = {
|
|
38
|
-
active: Flags.boolean({ description: 'Show active program detail' }),
|
|
39
|
-
current: Flags.boolean({ description: 'Alias for --active' }),
|
|
40
|
-
};
|
|
37
|
+
static flags = {};
|
|
41
38
|
async run() {
|
|
42
|
-
const { args
|
|
39
|
+
const { args } = await this.parse(ProgramsShow);
|
|
43
40
|
const context = openDb();
|
|
44
41
|
try {
|
|
45
|
-
const
|
|
46
|
-
if (args.selector && useActive) {
|
|
47
|
-
throw new Error('Use either a selector or --active/--current, not both.');
|
|
48
|
-
}
|
|
49
|
-
if (!args.selector && !useActive) {
|
|
50
|
-
throw new Error('Provide a selector or use --active/--current.');
|
|
51
|
-
}
|
|
52
|
-
const programId = await resolveProgramSelector(context.db, args.selector, Boolean(useActive));
|
|
42
|
+
const programId = await resolveProgramSelector(context.db, args.selector, !args.selector);
|
|
53
43
|
const detail = await getProgramDetail(context.db, programId);
|
|
54
44
|
const unitPreference = await resolveProgramWeightUnit(context.db, detail.program.id);
|
|
55
45
|
const unitLabel = weightUnitLabel(unitPreference);
|
|
@@ -57,7 +47,8 @@ export default class ProgramsShow extends Command {
|
|
|
57
47
|
return serializeProgramDetailWithWeightUnits(detail, unitPreference);
|
|
58
48
|
}
|
|
59
49
|
this.log(`[${detail.program.id}] ${detail.program.name}`);
|
|
60
|
-
this.log(`Active: ${detail.program.isActive}
|
|
50
|
+
this.log(`Active: ${detail.program.isActive}`);
|
|
51
|
+
this.log(`Template: ${detail.program.isTemplate}`);
|
|
61
52
|
this.log('');
|
|
62
53
|
const programRows = buildProgramRows(detail.weeks, unitLabel);
|
|
63
54
|
const renderedTable = renderTable(programRows).replace(/^\n+/, '');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class WorkoutsShow extends Command {
|
|
3
3
|
static args: {
|
|
4
|
-
workoutId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
4
|
+
workoutId: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static enableJsonFlag: boolean;
|
|
@@ -3,7 +3,7 @@ import { format, isValid, parseISO } from 'date-fns';
|
|
|
3
3
|
import { closeDb, openDb } from '../../lib/db.js';
|
|
4
4
|
import { serializeWorkoutDetailWithWeightUnits } from '../../lib/json-weight.js';
|
|
5
5
|
import { renderTable } from '../../lib/output.js';
|
|
6
|
-
import { getWorkoutDetail } from '../../lib/repositories/workouts.js';
|
|
6
|
+
import { getWorkoutDetail, listWorkouts } from '../../lib/repositories/workouts.js';
|
|
7
7
|
import { resolveGlobalWeightUnit, weightUnitLabel } from '../../lib/units.js';
|
|
8
8
|
function formatDurationMinutes(durationSeconds) {
|
|
9
9
|
if (durationSeconds === null)
|
|
@@ -20,7 +20,7 @@ function formatWorkoutDate(dateIso) {
|
|
|
20
20
|
}
|
|
21
21
|
export default class WorkoutsShow extends Command {
|
|
22
22
|
static args = {
|
|
23
|
-
workoutId: Args.string({ description: 'workout id', required:
|
|
23
|
+
workoutId: Args.string({ description: 'workout id (default: latest workout)', required: false }),
|
|
24
24
|
};
|
|
25
25
|
static description = 'Show one workout with exercises and sets';
|
|
26
26
|
static enableJsonFlag = true;
|
|
@@ -28,10 +28,17 @@ export default class WorkoutsShow extends Command {
|
|
|
28
28
|
const { args } = await this.parse(WorkoutsShow);
|
|
29
29
|
const context = openDb();
|
|
30
30
|
try {
|
|
31
|
-
if (!/^\d+$/.test(args.workoutId)) {
|
|
32
|
-
throw new Error('Workout
|
|
31
|
+
if (args.workoutId !== undefined && !/^\d+$/.test(args.workoutId)) {
|
|
32
|
+
throw new Error('Workout id must be numeric.');
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const workoutId = args.workoutId
|
|
35
|
+
? Number(args.workoutId)
|
|
36
|
+
: await listWorkouts(context.db, { limit: 1 }).then((rows) => {
|
|
37
|
+
if (rows.length === 0)
|
|
38
|
+
throw new Error('No workouts found.');
|
|
39
|
+
return rows[0].id;
|
|
40
|
+
});
|
|
41
|
+
const detail = await getWorkoutDetail(context.db, workoutId);
|
|
35
42
|
const unitPreference = await resolveGlobalWeightUnit(context.db);
|
|
36
43
|
const unitLabel = weightUnitLabel(unitPreference);
|
|
37
44
|
if (this.jsonEnabled()) {
|
|
@@ -54,7 +54,7 @@ export async function resolveProgramSelector(db, selector, activeOnly) {
|
|
|
54
54
|
return fallbackRows[0].id;
|
|
55
55
|
}
|
|
56
56
|
if (!selector)
|
|
57
|
-
throw new Error('Program selector is required
|
|
57
|
+
throw new Error('Program selector is required.');
|
|
58
58
|
const programId = await resolveIdOrName(db, 'ZWORKOUTPLAN', selector);
|
|
59
59
|
const nonDeleted = await db
|
|
60
60
|
.selectFrom('ZWORKOUTPLAN')
|
|
@@ -73,7 +73,12 @@ export async function getWorkoutDetail(db, workoutId) {
|
|
|
73
73
|
.selectFrom('ZEXERCISERESULT as er')
|
|
74
74
|
.leftJoin('ZEXERCISECONFIGURATION as ec', 'ec.Z_PK', 'er.ZCONFIGURATION')
|
|
75
75
|
.leftJoin('ZEXERCISEINFORMATION as ei', 'ei.Z_PK', 'ec.ZINFORMATION')
|
|
76
|
-
.select([
|
|
76
|
+
.select([
|
|
77
|
+
'er.Z_PK as exerciseResultId',
|
|
78
|
+
'ei.Z_PK as exerciseId',
|
|
79
|
+
'ei.ZISUSERCREATED as isUserCreated',
|
|
80
|
+
'ei.ZNAME as exerciseName',
|
|
81
|
+
])
|
|
77
82
|
.where('er.ZWORKOUT', '=', workoutId)
|
|
78
83
|
.orderBy('er.Z_FOK_WORKOUT', 'asc')
|
|
79
84
|
.orderBy('er.Z_PK', 'asc')
|
package/oclif.manifest.json
CHANGED
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"aliases": [],
|
|
211
211
|
"args": {
|
|
212
212
|
"selector": {
|
|
213
|
-
"description": "program id or name",
|
|
213
|
+
"description": "program id or name (default: active program)",
|
|
214
214
|
"name": "selector",
|
|
215
215
|
"required": false
|
|
216
216
|
}
|
|
@@ -223,18 +223,6 @@
|
|
|
223
223
|
"name": "json",
|
|
224
224
|
"allowNo": false,
|
|
225
225
|
"type": "boolean"
|
|
226
|
-
},
|
|
227
|
-
"active": {
|
|
228
|
-
"description": "Show active program detail",
|
|
229
|
-
"name": "active",
|
|
230
|
-
"allowNo": false,
|
|
231
|
-
"type": "boolean"
|
|
232
|
-
},
|
|
233
|
-
"current": {
|
|
234
|
-
"description": "Alias for --active",
|
|
235
|
-
"name": "current",
|
|
236
|
-
"allowNo": false,
|
|
237
|
-
"type": "boolean"
|
|
238
226
|
}
|
|
239
227
|
},
|
|
240
228
|
"hasDynamicHelp": false,
|
|
@@ -350,9 +338,9 @@
|
|
|
350
338
|
"aliases": [],
|
|
351
339
|
"args": {
|
|
352
340
|
"workoutId": {
|
|
353
|
-
"description": "workout id",
|
|
341
|
+
"description": "workout id (default: latest workout)",
|
|
354
342
|
"name": "workoutId",
|
|
355
|
-
"required":
|
|
343
|
+
"required": false
|
|
356
344
|
}
|
|
357
345
|
},
|
|
358
346
|
"description": "Show one workout with exercises and sets",
|
|
@@ -382,5 +370,5 @@
|
|
|
382
370
|
]
|
|
383
371
|
}
|
|
384
372
|
},
|
|
385
|
-
"version": "1.
|
|
373
|
+
"version": "1.2.0"
|
|
386
374
|
}
|