mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-06-05 15:09:59 +09:00
Remove aliases
This commit is contained in:
+1
-35
@@ -27,42 +27,36 @@ const options = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'year-folders',
|
name: 'year-folders',
|
||||||
aliases: ['yearfolders', 'yearmonthfolders'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Create year folders',
|
description: 'Create year folders',
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'month-folders',
|
name: 'month-folders',
|
||||||
aliases: ['yearmonthfolders'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Create month folders',
|
description: 'Create month folders',
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'post-folders',
|
name: 'post-folders',
|
||||||
aliases: ['postfolders'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Create a folder for each post',
|
description: 'Create a folder for each post',
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'prefix-date',
|
name: 'prefix-date',
|
||||||
aliases: ['prefixdate'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Prefix post folders/files with date',
|
description: 'Prefix post folders/files with date',
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'save-attached-images',
|
name: 'save-attached-images',
|
||||||
aliases: ['saveimages'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Save images attached to posts',
|
description: 'Save images attached to posts',
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'save-scraped-images',
|
name: 'save-scraped-images',
|
||||||
aliases: ['addcontentimages'],
|
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Save images scraped from post body content',
|
description: 'Save images scraped from post body content',
|
||||||
default: true
|
default: true
|
||||||
@@ -77,8 +71,7 @@ const options = [
|
|||||||
|
|
||||||
export async function getConfig(argv) {
|
export async function getConfig(argv) {
|
||||||
extendOptionsData();
|
extendOptionsData();
|
||||||
const unaliasedArgv = replaceAliases(argv);
|
const opts = parseCommandLine(argv);
|
||||||
const opts = parseCommandLine(unaliasedArgv);
|
|
||||||
|
|
||||||
let answers;
|
let answers;
|
||||||
if (opts.wizard) {
|
if (opts.wizard) {
|
||||||
@@ -127,33 +120,6 @@ function extendOptionsData() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAliases(argv) {
|
|
||||||
let paths = argv.slice(0, 2);
|
|
||||||
let replaced = [];
|
|
||||||
let unmodified = [];
|
|
||||||
|
|
||||||
argv.slice(2).forEach(arg => {
|
|
||||||
let aliasFound = false;
|
|
||||||
|
|
||||||
// this loop does not short circuit because an alias can map to multiple options
|
|
||||||
options.forEach(option => {
|
|
||||||
const aliases = option.aliases || [];
|
|
||||||
aliases.forEach(alias => {
|
|
||||||
if (arg.includes('--' + alias)) {
|
|
||||||
replaced.push(arg.replace('--' + alias, '--' + option.name));
|
|
||||||
aliasFound = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!aliasFound) {
|
|
||||||
unmodified.push(arg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return [...paths, ...replaced, ...unmodified];
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCommandLine(argv) {
|
function parseCommandLine(argv) {
|
||||||
// setup for help output
|
// setup for help output
|
||||||
commander.program
|
commander.program
|
||||||
|
|||||||
Reference in New Issue
Block a user