Merge pull request #4496 from GHolk/arg-fork

Fix negative number not parsed in findnext command
This commit is contained in:
Oliver Blanthorn 2022-12-13 17:01:19 +01:00 committed by GitHub
commit f767f7a05c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 31 deletions

View file

@ -12,7 +12,6 @@
"stream": "stream-browserify"
},
"dependencies": {
"arg": "^5.0.2",
"cleanslate": "^0.10.1",
"csp-serdes": "github:cmcaine/csp-serdes",
"css": "^3.0.0",
@ -23,6 +22,7 @@
"ramda": "^0.28.0",
"semver-compare": "^1.0.0",
"stream-browserify": "^3.0.0",
"tridactyl-arg": "git+https://github.com/GHolk/arg.git#v5.1.0",
"tsdef": "^0.0.14",
"typedoc": "^0.19.2",
"typedoc-default-themes": "^0.12.10"

View file

@ -1460,7 +1460,11 @@ export function find(...args: string[]) {
"--reverse": Boolean,
"-?": "--reverse",
},
{ argv: args, permissive: true },
{
argv: args,
permissive: true,
splitUnknownArguments: false,
},
)
const option = {}
option["reverse"] = Boolean(argOpt["--reverse"])
@ -1489,7 +1493,10 @@ export function findnext(...args: string[]) {
"--reverse": Boolean,
"-?": "--reverse",
},
{ argv: args },
{
argv: args,
allowNegativePositional: true,
},
)
if (option._.length > 0) n = Number(option._[0])
if (option["--reverse"]) n = -n

View file

@ -1,36 +1,15 @@
import arg from "arg"
import arg from "tridactyl-arg"
/**
* The arguments parsing library name
*/
export const name = "arg"
export const name = "tridactyl-arg"
/**
* The imported library itself
*/
export const lib = arg
/**
* Function to easily allow some single hyphen prefix option
* to be treated as long option too.
*
* E.g. correctSingleHyphen("-private https://some.url".split(" "), "-private")
* will retrun "--private http://some.url".split(" "), which can be parsed
* as a normal long option.
*/
export function correctSingleHyphen(
argv: string[],
...singleNames: string[]
): string[] {
return argv.map(arg => {
const scan = /^-[\w-]{2,}/.exec(arg)
if (!scan) return arg
const index = singleNames.indexOf(scan[0])
if (index === -1) return arg
else return "-" + arg
})
}
/**
* Small function to test if the double hyphen is the last option.
* If a command does not expect empty arguments, and user just pass "--"

View file

@ -1306,11 +1306,6 @@ anymatch@^3.0.3:
normalize-path "^3.0.0"
picomatch "^2.0.4"
arg@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c"
integrity sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@ -7106,6 +7101,10 @@ tr46@^1.0.1:
dependencies:
punycode "^2.1.0"
"tridactyl-arg@git+https://github.com/GHolk/arg.git#v5.1.0":
version "5.1.0"
resolved "git+https://github.com/GHolk/arg.git#28f3f1d9e2828b7c58d61ba5cce2ffa242374c63"
trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"