From d752077cd66196d5af1183e391bb71413c8b34f9 Mon Sep 17 00:00:00 2001 From: gardenapple Date: Sun, 9 Aug 2020 18:05:25 +0300 Subject: [PATCH] Rename --url to --base --- index.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b2e0aed..99c66eb 100644 --- a/index.js +++ b/index.js @@ -46,11 +46,12 @@ Usage: (where SOURCE is a file, an http(s) URL, or '-' for standard input) Options: + -b --base URL Set URL as the base for relative links, useful when parsing local files or standard input -h --help Print help -o --output OUTPUT_FILE Output to OUTPUT_FILE -p --properties PROPS... Output specific properties of the parsed article -V --version Print version - -u --url Set the document URL when parsing standard input or a local file (this affects relative links) + -u --url (deprecated) alias for --base -U --is-url Interpret SOURCE as a URL rather than file name -q --quiet Don't output extra information to stderr -l --low-confidence MODE What to do if Readability.js is uncertain about what the core content actually is @@ -80,13 +81,14 @@ Default value is "html-title,html-content".`); -const stringArgParams = ['_', "--", "low-confidence", "output", "properties", "url"]; +const stringArgParams = ['_', "--", "low-confidence", "output", "properties", "url", "base"]; const boolArgParams = ["quiet", "help", "version", "is-url"]; const alias = { + "url": 'u', "output": 'o', "properties": 'p', "version": 'V', - "url": 'u', + "base": 'b', "is-url": 'U', "quiet": 'q', "low-confidence": 'l', @@ -105,6 +107,15 @@ let args = parseArgs(process.argv.slice(2), { }); +//Backwards compat +if (args['u']) + args['b'] = args['u']; +if (args["url"]) { + console.error("Note: the --url option is deprecated, use --base or -b instead"); + args["base"] = args["url"]; +} + + //Minimist's parseArgs accepts a function for handling unknown parameters, //but it works in a stupid way, so I'm writing my own. @@ -173,7 +184,7 @@ delete args['--']; const outputArg = args['output']; -const documentURL = args["url"] || inputURL; +const documentURL = args["base"] || inputURL; @@ -238,7 +249,7 @@ if (inputIsFromStdin) { if (!documentURL) console.error("Note: piping input with unknown " + "URL. This means that relative links will " + - "be broken. Supply the --url parameter to fix.") + "be broken. Supply the --base parameter to fix.") } read(process.stdin).then(result => { const JSDOM = require("jsdom").JSDOM;