Skip to content

Commit 4def464

Browse files
committed
feat(cli): add non-bool flags in video command
1 parent aee1260 commit 4def464

File tree

1 file changed

+51
-13
lines changed

1 file changed

+51
-13
lines changed

src/cli/commands/video-command.ts

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export class VideoCommand extends Command {
2525
private readonly widthFlag = 'width';
2626
private readonly heightFlag = 'height';
2727
private readonly closeGameAfterRecordingFlag = 'close-game-after-recording';
28+
private readonly noCloseGameAfterRecordingFlag = 'no-close-game-after-recording';
2829
private readonly concatenateSequencesFlag = 'concatenate-sequences';
30+
private readonly noConcatenateSequencesFlag = 'no-concatenate-sequences';
2931
private readonly encoderSoftwareFlag = 'encoder-software';
3032
private readonly recordingSystemFlag = 'recording-system';
3133
private readonly recordingOutputFlag = 'recording-output';
@@ -37,8 +39,11 @@ export class VideoCommand extends Command {
3739
private readonly ffmpegInputParametersFlag = 'ffmpeg-input-parameters';
3840
private readonly ffmpegOutputParametersFlag = 'ffmpeg-output-parameters';
3941
private readonly showXRayFlag = 'show-x-ray';
42+
private readonly noShowXRayFlag = 'no-show-x-ray';
4043
private readonly showOnlyDeathNoticesFlag = 'show-only-death-notices';
44+
private readonly noShowOnlyDeathNoticesFlag = 'no-show-only-death-notices';
4145
private readonly playerVoicesFlag = 'player-voices';
46+
private readonly noPlayerVoicesFlag = 'no-player-voices';
4247
private readonly deathNoticesDurationFlag = 'death-notices-duration';
4348
private readonly cfgFlag = 'cfg';
4449
private outputFolderPath: string | undefined;
@@ -82,7 +87,9 @@ export class VideoCommand extends Command {
8287
console.log(` --${this.widthFlag} <number>`);
8388
console.log(` --${this.heightFlag} <number>`);
8489
console.log(` --${this.closeGameAfterRecordingFlag}`);
90+
console.log(` --${this.noCloseGameAfterRecordingFlag}`);
8591
console.log(` --${this.concatenateSequencesFlag}`);
92+
console.log(` --${this.noConcatenateSequencesFlag}`);
8693
console.log(` --${this.encoderSoftwareFlag} <string> (FFmpeg or VirtualDub)`);
8794
console.log(` --${this.recordingSystemFlag} <string> (HLAE or CS)`);
8895
console.log(` --${this.recordingOutputFlag} <string> (video, images, or images-and-video)`);
@@ -94,8 +101,11 @@ export class VideoCommand extends Command {
94101
console.log(` --${this.ffmpegInputParametersFlag} <string>`);
95102
console.log(` --${this.ffmpegOutputParametersFlag} <string>`);
96103
console.log(` --${this.showXRayFlag}`);
104+
console.log(` --${this.noShowXRayFlag}`);
97105
console.log(` --${this.showOnlyDeathNoticesFlag}`);
106+
console.log(` --${this.noShowOnlyDeathNoticesFlag}`);
98107
console.log(` --${this.playerVoicesFlag}`);
108+
console.log(` --${this.noPlayerVoicesFlag}`);
99109
console.log(` --${this.deathNoticesDurationFlag} <number>`);
100110
console.log(` --${this.cfgFlag} <string>`);
101111
}
@@ -189,7 +199,9 @@ export class VideoCommand extends Command {
189199
[this.widthFlag]: { type: 'string' },
190200
[this.heightFlag]: { type: 'string' },
191201
[this.closeGameAfterRecordingFlag]: { type: 'boolean' },
202+
[this.noCloseGameAfterRecordingFlag]: { type: 'boolean' },
192203
[this.concatenateSequencesFlag]: { type: 'boolean' },
204+
[this.noConcatenateSequencesFlag]: { type: 'boolean' },
193205
[this.encoderSoftwareFlag]: { type: 'string' },
194206
[this.recordingSystemFlag]: { type: 'string' },
195207
[this.recordingOutputFlag]: { type: 'string' },
@@ -201,8 +213,11 @@ export class VideoCommand extends Command {
201213
[this.ffmpegInputParametersFlag]: { type: 'string' },
202214
[this.ffmpegOutputParametersFlag]: { type: 'string' },
203215
[this.showXRayFlag]: { type: 'boolean' },
216+
[this.noShowXRayFlag]: { type: 'boolean' },
204217
[this.showOnlyDeathNoticesFlag]: { type: 'boolean' },
218+
[this.noShowOnlyDeathNoticesFlag]: { type: 'boolean' },
205219
[this.playerVoicesFlag]: { type: 'boolean' },
220+
[this.noPlayerVoicesFlag]: { type: 'boolean' },
206221
[this.deathNoticesDurationFlag]: { type: 'string' },
207222
[this.cfgFlag]: { type: 'string' },
208223
},
@@ -287,35 +302,43 @@ export class VideoCommand extends Command {
287302
this.height = height;
288303
}
289304
const closeGameAfterRecording = values[this.closeGameAfterRecordingFlag];
290-
if (closeGameAfterRecording) {
305+
if (closeGameAfterRecording !== undefined) {
291306
this.closeGameAfterRecording = true;
292307
}
308+
const noCloseGameAfterRecording = values[this.noCloseGameAfterRecordingFlag];
309+
if (noCloseGameAfterRecording !== undefined) {
310+
this.closeGameAfterRecording = false;
311+
}
293312
const concatenateSequences = values[this.concatenateSequencesFlag];
294-
if (concatenateSequences) {
313+
if (concatenateSequences !== undefined) {
295314
this.concatenateSequences = true;
296315
}
316+
const noConcatenateSequences = values[this.noConcatenateSequencesFlag];
317+
if (noConcatenateSequences !== undefined) {
318+
this.concatenateSequences = false;
319+
}
297320
const encoderSoftware = values[this.encoderSoftwareFlag];
298-
if (encoderSoftware) {
321+
if (encoderSoftware !== undefined) {
299322
if (!isValidEncoderSoftware(encoderSoftware)) {
300323
throw new InvalidArgument('Invalid encoder software');
301324
}
302325
this.encoderSoftware = encoderSoftware;
303326
}
304327
const recordingSystem = values[this.recordingSystemFlag];
305-
if (recordingSystem) {
328+
if (recordingSystem !== undefined) {
306329
if (!isValidRecordingSystem(recordingSystem)) {
307330
throw new InvalidArgument('Invalid recording system');
308331
}
309332
this.recordingSystem = recordingSystem;
310333
}
311334
const recordingOutput = values[this.recordingOutputFlag];
312-
if (recordingOutput) {
335+
if (recordingOutput !== undefined) {
313336
if (!isValidRecordingOutput(recordingOutput)) {
314337
throw new InvalidArgument('Invalid recording output');
315338
}
316339
this.recordingOutput = recordingOutput;
317340
}
318-
if (values[this.ffmpegCrfFlag]) {
341+
if (values[this.ffmpegCrfFlag] !== undefined) {
319342
const ffmpegCrf = Number(values[this.ffmpegCrfFlag]);
320343
if (Number.isNaN(ffmpegCrf)) {
321344
throw new InvalidArgument('FFmpeg CRF is not a number');
@@ -325,7 +348,7 @@ export class VideoCommand extends Command {
325348
}
326349
this.ffmpegCrf = ffmpegCrf;
327350
}
328-
if (values[this.ffmpegAudioBitrateFlag]) {
351+
if (values[this.ffmpegAudioBitrateFlag] !== undefined) {
329352
const ffmpegAudioBitrate = Number(values[this.ffmpegAudioBitrateFlag]);
330353
if (Number.isNaN(ffmpegAudioBitrate)) {
331354
throw new InvalidArgument('FFmpeg audio bitrate is not a number');
@@ -335,34 +358,49 @@ export class VideoCommand extends Command {
335358
}
336359
this.ffmpegAudioBitrate = ffmpegAudioBitrate;
337360
}
338-
if (values[this.ffmpegVideoCodecFlag]) {
361+
if (values[this.ffmpegVideoCodecFlag] !== undefined) {
339362
this.ffmpegVideoCodec = values[this.ffmpegVideoCodecFlag];
340363
}
341364
if (values[this.ffmpegAudioCodecFlag]) {
342365
this.ffmpegAudioCodec = values[this.ffmpegAudioCodecFlag];
343366
}
344367
const videoContainer = values[this.ffmpegVideoContainerFlag];
345-
if (videoContainer) {
368+
if (videoContainer !== undefined) {
346369
if (!isValidVideoContainer(videoContainer)) {
347370
throw new InvalidArgument('Invalid video container');
348371
}
349372
this.ffmpegVideoContainer = videoContainer;
350373
}
351-
if (values[this.ffmpegInputParametersFlag]) {
374+
if (values[this.ffmpegInputParametersFlag] !== undefined) {
352375
this.ffmpegInputParameters = values[this.ffmpegInputParametersFlag];
353376
}
354377
if (values[this.ffmpegOutputParametersFlag]) {
355378
this.ffmpegOutputParameters = values[this.ffmpegOutputParametersFlag];
356379
}
357-
if (values[this.showXRayFlag]) {
380+
const showXRay = values[this.showXRayFlag];
381+
if (showXRay !== undefined) {
358382
this.showXRay = true;
359383
}
360-
if (values[this.showOnlyDeathNoticesFlag]) {
384+
const noShowXRay = values[this.noShowXRayFlag];
385+
if (noShowXRay !== undefined) {
386+
this.showXRay = false;
387+
}
388+
const showOnlyDeathNotices = values[this.showOnlyDeathNoticesFlag];
389+
if (showOnlyDeathNotices !== undefined) {
361390
this.showOnlyDeathNotices = true;
362391
}
363-
if (values[this.playerVoicesFlag]) {
392+
const noShowOnlyDeathNotices = values[this.noShowOnlyDeathNoticesFlag];
393+
if (noShowOnlyDeathNotices !== undefined) {
394+
this.showOnlyDeathNotices = false;
395+
}
396+
const playerVoices = values[this.playerVoicesFlag];
397+
if (playerVoices !== undefined) {
364398
this.playerVoices = true;
365399
}
400+
const noPlayerVoices = values[this.noPlayerVoicesFlag];
401+
if (noPlayerVoices !== undefined) {
402+
this.playerVoices = false;
403+
}
366404
if (values[this.deathNoticesDurationFlag]) {
367405
const deathNoticesDuration = Number(values[this.deathNoticesDurationFlag]);
368406
if (Number.isNaN(deathNoticesDuration)) {

0 commit comments

Comments
 (0)