mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
parse_bind_args checks for flags with '--' prefix
This commit is contained in:
parent
e1cce5f2b9
commit
a9de0897b9
|
|
@ -27,6 +27,7 @@ interface bind_args {
|
|||
configName: string
|
||||
key: string
|
||||
excmd: string
|
||||
isRecursive: boolean
|
||||
}
|
||||
|
||||
export function parse_bind_args(...args: string[]): bind_args {
|
||||
|
|
@ -35,9 +36,21 @@ export function parse_bind_args(...args: string[]): bind_args {
|
|||
const result = {} as bind_args
|
||||
result.mode = "normal"
|
||||
|
||||
if (args[0].startsWith("--mode=")) {
|
||||
result.mode = args.shift().replace("--mode=", "")
|
||||
const flags = []; // --mode and --recursive
|
||||
while (args[0].startsWith("--")) {
|
||||
flags.push(args.shift());
|
||||
}
|
||||
|
||||
for (const flag of flags) {
|
||||
if (flag.startsWith("--mode")) {
|
||||
result.mode = flag.replace("--mode=", "");
|
||||
} else if (flag == "--recursive") {
|
||||
result.isRecursive = true;
|
||||
} else {
|
||||
throw new Error("Invalid bind/unbind arguments.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!mode2maps.has(result.mode)) {
|
||||
result.configName = result.mode + "maps"
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue