From a5520d11594cdaf7833fcf1137f0943955ea894c Mon Sep 17 00:00:00 2001 From: Nick Wronski Date: Sun, 27 Oct 2019 17:30:20 -0400 Subject: [PATCH] refactor: rename --force to --crop BREAKING CHANGE: the `--force` option has been renamed to `--crop` to be consistent with new `--nocrop` option --- README.md | 2 +- batch-transcode-video.js | 4 ++-- lib/default-options.js | 2 +- lib/help.js | 4 ++-- lib/video-file.js | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c8ed75..e04f43d 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ batch.cli(); - The output **directory** to hold the transcoded videos. If you do not specify an output directory then each transcoded file will be placed in the same directory as its source file. Note: if a source file is already in the same file format as the transcoded video (e.g.: both source and output are both `.mkv`) then you must specify an output directory, as the program will not overwrite existing files. - `--mask [pattern]` (Default: `**/*.{mp4,avi,mkv,m4v,ts,mov}`) (Alias: `-m`) - Search pattern to use for input directory. Note that the default pattern will search in nested directories. For more information about what values can be used, see the [glob](https://github.com/isaacs/node-glob) documentation. -- `--force` _Mixed values_ (Alias: `-f`) +- `--crop` _Mixed values_ (Alias: `-c`) - If you provide **an actual crop value** (e.g.: `"0:0:0:0"`) as the argument for this option, then that crop value will be used **for all videos**. - If you provide anything other than an actual crop value (e.g. `1`) as the argument for this option, then when crop detection returns conflicting crop values it will just use the least extreme crop value and continue transcoding. - `--diff` _Flag: does not accept a value_ (Default: `false`) diff --git a/batch-transcode-video.js b/batch-transcode-video.js index ea0b81b..ecf2531 100644 --- a/batch-transcode-video.js +++ b/batch-transcode-video.js @@ -14,14 +14,14 @@ let defs = { mask: 'm', help: 'h', version: 'v', - force: 'f', + crop: 'c', keep: 'k' }, boolean: [ 'debug', 'quiet', 'flatten', 'diff', 'help', 'version', 'keep', 'nocrop' ], string: [ - 'input', 'output', 'mask', 'force' + 'input', 'output', 'mask', 'crop' ], default: defaultOptions, unknown: function (arg) { diff --git a/lib/default-options.js b/lib/default-options.js index 6178412..26a5694 100644 --- a/lib/default-options.js +++ b/lib/default-options.js @@ -16,7 +16,7 @@ export default { // Only try to transcode videos that do not exist in the output directory diff: false, // If crop detection returns multiple values then take the least extreme crop - force: false, + crop: false, // Never delete any output files, no matter what happens keep: false, // Skip crop detection and do not pass a --crop value to transcode-video diff --git a/lib/help.js b/lib/help.js index 551daad..c0357d0 100644 --- a/lib/help.js +++ b/lib/help.js @@ -21,10 +21,10 @@ const args = [ alias: 'm' }, { - arg: 'force [crop]', + arg: 'crop [crop]', desc: 'If you provide an actual crop value (e.g.: "0:0:0:0") as the argument for this option, then that crop value will be used for all videos. If you provide anything other than an actual crop value (e.g. 1) as the argument for this option, then when crop detection returns conflicting crop values it will just use the least extreme crop value and continue transcoding.', def: 'false', - alias: 'f' + alias: 'c' }, { arg: 'diff', diff --git a/lib/video-file.js b/lib/video-file.js index e3aa418..2ee216d 100644 --- a/lib/video-file.js +++ b/lib/video-file.js @@ -129,12 +129,12 @@ export default class VideoFile { _detectCrop() { let prom; let isNoCrop = this.options['nocrop'] === true; - let isFixedCrop = /([0-9]+\:){3}[0-9]+/.test(this.options['force']); + let isFixedCrop = /([0-9]+\:){3}[0-9]+/.test(this.options['crop']); if (isNoCrop || isFixedCrop) { const useCommand = [ 'transcode-video' ]; if (isFixedCrop && !isNoCrop) { - // Force the crop value provided using the --force option - useCommand.push('--crop', this.options['force'].trim()); + // Force the crop value provided using the --crop option + useCommand.push('--crop', this.options['crop'].trim()); } useCommand.push(this.filePathRel); this._crop = prom = Promise.resolve(useCommand.join(' ')); @@ -158,7 +158,7 @@ export default class VideoFile { if (useCommands.length === 0) { throw new TranscodeError('Crop detection failed. Skipping transcode for file.', this.fileName, output); } else if (useCommands.length > 1) { - if (this.options['force'] !== false) { + if (this.options['crop'] !== false) { // Pick the least extreme crop useCommands.sort(cropCompareFunc); } else {