From ca4e4dcf5b0caf720beb1684bc6a36c29e578b12 Mon Sep 17 00:00:00 2001 From: walcutt Date: Tue, 24 Jun 2025 16:47:06 -0400 Subject: [PATCH] Add help command --- src/command-config.js | 7 +++++++ src/commands/help.js | 26 ++++++++++++++++++++++++++ src/pipeline.js | 8 ++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/commands/help.js diff --git a/src/command-config.js b/src/command-config.js index 6010eef..512c335 100644 --- a/src/command-config.js +++ b/src/command-config.js @@ -2,6 +2,7 @@ import { addSubtitleTrack } from "./commands/add-subs.js"; import { encodeX265 } from "./commands/encode-265.js"; import { extractToEpisodeNumber } from "./commands/extract-to-se.js"; import { finalizeFileNames } from "./commands/finalize-filenames.js"; +import { help } from "./commands/help.js"; import { preferAudio } from "./commands/prefer-audio.js"; import { preferSubtitles } from "./commands/prefer-subs.js"; import { removeSubtitles } from "./commands/remove-subs.js"; @@ -10,6 +11,12 @@ import { convertToMkv } from "./commands/to-mkv.js"; import { convertToMp4 } from "./commands/to-mp4.js"; export const CommandConfig = [ + { + name: 'Help', + commands: ['-help', 'help', '--help'], + params: [], + func: help, + }, { name: 'Extract To Episode Number', commands: ['-x', '-extract', '-extract-episode-number'], diff --git a/src/commands/help.js b/src/commands/help.js new file mode 100644 index 0000000..275e450 --- /dev/null +++ b/src/commands/help.js @@ -0,0 +1,26 @@ +import { CommandConfig } from "../command-config.js"; + +export function help(inputDir, inputFile, outputDir, options) { + console.log(''); + console.log('Add any of the following steps, in sequence, to form a pipeline.'); + console.log('The output of the last step will be the final output.'); + console.log('Inputs should go to ./inputs/'); + console.log('Outputs should go to ./outputs/'); + console.log('You should have space for up to (steps + 1) * (size of inputs)'); + + console.log('Available steps:'); + for(let i = 0; i < CommandConfig.length; i++) { + const line1 = ` - ${CommandConfig[i].name}:`; + let line2 = ` * `; + for(let k = 0; k < CommandConfig[i].commands.length; k++) { + if(k !== 0) { + line2 += ', '; + } + + line2 += CommandConfig[i].commands[k]; + } + + console.log(line1); + console.log(line2); + } +} \ No newline at end of file diff --git a/src/pipeline.js b/src/pipeline.js index 1a655e8..2e2540b 100644 --- a/src/pipeline.js +++ b/src/pipeline.js @@ -1,3 +1,4 @@ +import { help } from "./commands/help.js"; import { Folders } from "./constants/folders.js"; import { getAllCommands } from "./parsing/parse-commands.js"; import fs from 'fs'; @@ -7,6 +8,10 @@ export function CreatePipeline(inputParams) { return { commands: commands, async run() { + if(!commands || commands.length === 0) { + help(); + return; + } // Create /temp/Step-0 if(fs.existsSync(Folders.TEMP)) { fs.rmSync(Folders.TEMP, { recursive: true, force: true}); @@ -36,6 +41,9 @@ export function CreatePipeline(inputParams) { for(let k = 0; k < files.length; k++) { process.stdout.write(`${getStatus(this.commands[i].command, k, files.length)}\r`); const result = await func(inputDir, files[k], outputDir, params); + if(this.commands[i].command === 'Help') { + break; + } } process.stdout.write(`${getStatus(this.commands[i].command, files.length, files.length)}\n`); }