Add help command

This commit is contained in:
walcutt 2025-06-24 16:47:06 -04:00
parent e195ba7f68
commit ca4e4dcf5b
3 changed files with 41 additions and 0 deletions

View File

@ -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'],

26
src/commands/help.js Normal file
View File

@ -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);
}
}

View File

@ -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`);
}