Skip to content

Commit

Permalink
Refactor: separate 'clean' help message options (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm committed Jul 14, 2024
1 parent 0f0c9aa commit 8c7993d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/modules/argumentsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ export default class ArgumentsParser {
const groupDatInput = 'DAT input options:';
const groupPatchInput = 'Patch input options:';
const groupRomOutput = 'ROM output options (processed in order):';
const groupRomZip = 'ROM zip command options:';
const groupRomLink = 'ROM link command options:';
const groupRomClean = 'clean command options:';
const groupRomZip = 'zip command options:';
const groupRomLink = 'link command options:';
const groupRomHeader = 'ROM header options:';
const groupRomSet = 'ROM set options:';
const groupRomFiltering = 'ROM filtering options:';
const groupRomPriority = 'One game, one ROM (1G1R) options:';
const groupReport = 'Report options:';
const groupReport = 'report command options:';
const groupHelpDebug = 'Help & debug options:';

// Add every command to a yargs object, recursively, resulting in the ability to specify
Expand Down Expand Up @@ -410,27 +411,34 @@ export default class ArgumentsParser {
description: 'Overwrite files in the output directory that are the wrong filesize, checksum, or zip contents',
type: 'boolean',
})
.check((checkArgv) => {
if (checkArgv.help) {
return true;
}
const needOutput = ['copy', 'move', 'link', 'symlink', 'extract', 'zip', 'clean'].filter((command) => checkArgv._.includes(command));
if (!checkArgv.output && needOutput.length > 0) {
// TODO(cememr): print help message
throw new ExpectedError(`Missing required argument for command${needOutput.length !== 1 ? 's' : ''} ${needOutput.join(', ')}: --output <path>`);
}
return true;
})

.option('clean-exclude', {
group: groupRomOutput,
group: groupRomClean,
alias: 'C',
description: 'Path(s) to files to exclude from cleaning (supports globbing)',
type: 'array',
requiresArg: true,
})
.option('clean-dry-run', {
group: groupRomOutput,
group: groupRomClean,
description: 'Don\'t clean any files and instead only print what files would be cleaned',
type: 'boolean',
})
.check((checkArgv) => {
if (checkArgv.help) {
return true;
}
const needOutput = ['copy', 'move', 'link', 'symlink', 'extract', 'zip', 'clean'].filter((command) => checkArgv._.includes(command));
if (!checkArgv.output && needOutput.length > 0) {
// TODO(cememr): print help message
throw new ExpectedError(`Missing required argument for command${needOutput.length !== 1 ? 's' : ''} ${needOutput.join(', ')}: --output <path>`);
}
const needClean = ['clean-exclude', 'clean-dry-run'].filter((option) => checkArgv[option]);
if (!checkArgv._.includes('clean') && needClean.length > 0) {
// TODO(cememr): print help message
Expand Down
1 change: 1 addition & 0 deletions src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface OptionsProps {
readonly dirGameSubdir?: string,
readonly overwrite?: boolean,
readonly overwriteInvalid?: boolean,

readonly cleanExclude?: string[],
readonly cleanDryRun?: boolean,

Expand Down

0 comments on commit 8c7993d

Please sign in to comment.