Rename no-op to keep and alphabetize --help

merge-requests/2/head
gardenapple 3 years ago
parent a91521846c
commit eaaa11f808
No known key found for this signature in database
GPG Key ID: CAF17E9ABE789268

@ -88,7 +88,7 @@ const Properties = new Map([
]); ]);
const LowConfidenceMode = { const LowConfidenceMode = {
noOp: "no-op", keep: "keep",
force: "force", force: "force",
exit: "exit" exit: "exit"
}; };
@ -162,30 +162,54 @@ let args = yargs
defaultCompletion(); defaultCompletion();
}) })
.middleware([ yargsCompatProperties, yargsFixPositional ], true) //middleware seems to be buggy .middleware([ yargsCompatProperties, yargsFixPositional ], true) //middleware seems to be buggy
.option("help", {
alias: 'h',
desc: __`Show help`
})
.option("base", {
alias: 'b',
type: "string",
desc: __`Set the document URL when parsing standard input or a local file (this affects relative links)`
})
.option("completion", { .option("completion", {
type: "boolean", type: "boolean",
desc: __`Print script for bash/zsh completion` desc: __`Print script for bash/zsh completion`
}) })
.option("version", { .option("insane", {
alias: 'V', alias: 'S',
type: "boolean", type: "boolean",
desc: __`Print version` desc: __`Don't sanitize HTML`
}) })
.option("help", { .option("is-file", {
alias: 'h', alias: 'f',
desc: __`Show help` type: "boolean",
desc: __`Interpret SOURCE as a file name rather than a URL`,
default: false,
hidden: true,
//deprecated: true
}) })
.option("output", { .option("is-url", {
alias: 'o', alias: 'U',
type: "string", type: "boolean",
desc: __`The file to which the result should be output` desc: __`(deprecated) Interpret SOURCE as a URL rather than file name`,
hidden: true,
//deprecated: true
})
.option("json", {
alias: 'j',
type: "boolean",
desc: __`Output properties as a JSON payload`
}) })
.option("low-confidence", { .option("low-confidence", {
alias: 'l', alias: 'l',
type: "string", type: "string",
desc: __`What to do if Readability.js is uncertain about what the core content actually is`, desc: __`What to do if Readability.js is uncertain about what the core content actually is`,
//default: "no-op", //don't set default because completion won't work //default: "no-op", //don't set default because completion won't work
choices: ["no-op", "force", "exit"] })
.option("output", {
alias: 'o',
type: "string",
desc: __`The file to which the result should be output`
}) })
.option("properties", { .option("properties", {
alias: 'p', alias: 'p',
@ -199,11 +223,6 @@ let args = yargs
desc: __`Don't output extra information to stderr`, desc: __`Don't output extra information to stderr`,
default: false default: false
}) })
.option("base", {
alias: 'b',
type: "string",
desc: __`Set the document URL when parsing standard input or a local file (this affects relative links)`
})
.option("url", { .option("url", {
alias: 'u', alias: 'u',
type: "string", type: "string",
@ -211,37 +230,17 @@ let args = yargs
hidden: true, hidden: true,
//deprecated: true //completion script does not respect this value, so just say it in the description //deprecated: true //completion script does not respect this value, so just say it in the description
}) })
.option("is-file", { .option("version", {
alias: 'f', alias: 'V',
type: "boolean",
desc: __`Interpret SOURCE as a file name rather than a URL`,
default: false,
hidden: true,
//deprecated: true
})
.option("is-url", {
alias: 'U',
type: "boolean",
desc: __`(deprecated) Interpret SOURCE as a URL rather than file name`,
hidden: true,
//deprecated: true
})
.option("insane", {
alias: 'S',
type: "boolean",
desc: __`Don't sanitize HTML`
})
.option("json", {
alias: 'j',
type: "boolean", type: "boolean",
desc: __`Output properties as a JSON payload` desc: __`Print version`
}) })
.epilogue(__`The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n` + .epilogue(__`The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n` +
__` no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n` + __` keep When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n` +
__` force Process the document even when unsure (may produce really bad output).\n` + __` force Process the document even when unsure (may produce really bad output).\n` +
__` exit When unsure, exit with an error.\n` + __` exit When unsure, exit with an error.\n` +
'\n' + '\n' +
__`Default value is "no-op".\n` + __`Default value is "keep".\n` +
'\n' + '\n' +
'\n' + '\n' +
__`The --properties option accepts a list of values, separated by spaces. Suitable values are:\n` + __`The --properties option accepts a list of values, separated by spaces. Suitable values are:\n` +
@ -261,8 +260,17 @@ __`Default value is "html-title html-content".\n`)
.parse(); .parse();
if (!args["low-confidence"]) { if (!args["low-confidence"]) {
args["low-confidence"] = LowConfidenceMode.noOp; args["low-confidence"] = LowConfidenceMode.keep;
args['l'] = LowConfidenceMode.noOp; args['l'] = LowConfidenceMode.keep;
} else if (args["low-confidence"] == "no-op") {
console.error(__`Note: no-op option is deprecated, please use 'keep' instead.`);
args["low-confidence"] = LowConfidenceMode.keep;
args['l'] = LowConfidenceMode.keep;
} else if (!Object.values(LowConfidenceMode).includes(args["low-confidence"])) {
console.error(__`Unknown mode: ${args["low-confidence"]}\nPlease use one of: keep, force, exit`);
console.error(__`Use --help for more info.`);
setErrored(ExitCodes.badUsageCLI);
process.exit();
} }
if (args["is-url"]) { if (args["is-url"]) {

@ -15,10 +15,10 @@
"(deprecated) Interpret SOURCE as a URL rather than file name": "(deprecated) Interpret SOURCE as a URL rather than file name", "(deprecated) Interpret SOURCE as a URL rather than file name": "(deprecated) Interpret SOURCE as a URL rather than file name",
"Output properties as a JSON payload": "Output properties as a JSON payload", "Output properties as a JSON payload": "Output properties as a JSON payload",
"The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n": "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n", "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n": "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n",
" no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n", " keep When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " keep When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n",
" force Process the document even when unsure (may produce really bad output).\n": " force Process the document even when unsure (may produce really bad output).\n", " force Process the document even when unsure (may produce really bad output).\n": " force Process the document even when unsure (may produce really bad output).\n",
" exit When unsure, exit with an error.\n": " exit When unsure, exit with an error.\n", " exit When unsure, exit with an error.\n": " exit When unsure, exit with an error.\n",
"Default value is \"no-op\".\n": "Default value is \"no-op\".\n", "Default value is \"keep\".\n": "Default value is \"keep\".\n",
"The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n", "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n",
" title The title of the article.\n": " title The title of the article.\n", " title The title of the article.\n": " title The title of the article.\n",
" html-title The title of the article, wrapped in an <h1> tag.\n": " html-title The title of the article, wrapped in an <h1> tag.\n", " html-title The title of the article, wrapped in an <h1> tag.\n": " html-title The title of the article, wrapped in an <h1> tag.\n",
@ -42,5 +42,8 @@
"Not sure if this document should be processed, exiting": "Not sure if this document should be processed, exiting", "Not sure if this document should be processed, exiting": "Not sure if this document should be processed, exiting",
"Can't output properties": "Can't output properties", "Can't output properties": "Can't output properties",
"Couldn't process document.": "Couldn't process document.", "Couldn't process document.": "Couldn't process document.",
"Host not found: '%s'": "Host not found: '%s'" "Host not found: '%s'": "Host not found: '%s'",
"Unknown mode: %s\nPlease use one of: keep, force, exit": "Unknown mode: %s\nPlease use one of: keep, force, exit",
"Use --help for more info.": "Use --help for more info.",
"Note: no-op option is deprecated, please use 'keep' instead.": "Note: no-op option is deprecated, please use 'keep' instead."
} }

@ -15,10 +15,10 @@
"(deprecated) Interpret SOURCE as a URL rather than file name": "(устаревшее) Интерпретировать [source] как URL, а не как файл", "(deprecated) Interpret SOURCE as a URL rather than file name": "(устаревшее) Интерпретировать [source] как URL, а не как файл",
"Output properties as a JSON payload": "Показать характеристики текста в формате JSON", "Output properties as a JSON payload": "Показать характеристики текста в формате JSON",
"The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n": "Параметр --low-confidence определяет, что следует делать, если Readability не может определить целевой контент:\n", "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n": "Параметр --low-confidence определяет, что следует делать, если Readability не может определить целевой контент:\n",
" no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " no-op В случае неуверенности, не трогать HTML, выдавать как есть. Не совместимо с параметрами --properties и --json.\n", " keep When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " keep В случае неуверенности, не трогать HTML, выдавать как есть. Не совместимо с параметрами --properties и --json.\n",
" force Process the document even when unsure (may produce really bad output).\n": " force Обработать документ даже в случае неуверенности (может выдать плохой результат).\n", " force Process the document even when unsure (may produce really bad output).\n": " force Обработать документ даже в случае неуверенности (может выдать плохой результат).\n",
" exit When unsure, exit with an error.\n": " exit В случае неуверенности, выдать ошибку и выйти.\n", " exit When unsure, exit with an error.\n": " exit В случае неуверенности, выдать ошибку и выйти.\n",
"Default value is \"no-op\".\n": "По умолчанию выполняется \"no-op\".\n", "Default value is \"keep\".\n": "По умолчанию выполняется \"keep\".\n",
"The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "Параметр --properties принимает список значений (разделённых пробелами):\n", "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "Параметр --properties принимает список значений (разделённых пробелами):\n",
" title The title of the article.\n": " title Заголовок статьи.\n", " title The title of the article.\n": " title Заголовок статьи.\n",
" html-title The title of the article, wrapped in an <h1> tag.\n": " html-title Заголовок статьи в тэге <h1>.\n", " html-title The title of the article, wrapped in an <h1> tag.\n": " html-title Заголовок статьи в тэге <h1>.\n",
@ -42,5 +42,8 @@
"Not sure if this document should be processed, exiting": "Не уверен, стоит ли обрабатывать этот документ - выхожу", "Not sure if this document should be processed, exiting": "Не уверен, стоит ли обрабатывать этот документ - выхожу",
"Can't output properties": "Не могу определить характеристики", "Can't output properties": "Не могу определить характеристики",
"Couldn't process document.": "Не удалось обработать документ.", "Couldn't process document.": "Не удалось обработать документ.",
"Host not found: '%s'": "Сервер не найден: '%s'" "Host not found: '%s'": "Сервер не найден: '%s'",
"Unknown mode: %s\nPlease use one of: keep, force, exit": "Неизвестный режим: %s\nПожалуйста, используйте один из: keep, force, exit",
"Use --help for more info.": "Чтобы узнать больше, воспользуйтесь --help",
"Note: no-op option is deprecated, please use 'keep' instead.": "Внимание: параметр no-op устаревшый, используйте вместо него 'keep'."
} }

Loading…
Cancel
Save