forked from tools/josh
parent
6e55ffa217
commit
fee631e216
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fwdekker.com",
|
||||
"version": "0.39.7",
|
||||
"version": "0.39.8",
|
||||
"description": "The source code of [my personal website](https://fwdekker.com/).",
|
||||
"author": "Felix W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -126,12 +126,12 @@ export class InputParser {
|
|||
}
|
||||
|
||||
const argsParts = arg.split("=");
|
||||
if (argsParts.length === 0 || argsParts.length > 2)
|
||||
if (argsParts.length === 0)
|
||||
throw new IllegalArgumentError("Unexpected number of parts.");
|
||||
if (argsParts[0].includes(" ") || argsParts[0].match(/[0-9]/))
|
||||
break;
|
||||
|
||||
const value = argsParts.length === 1 ? null : argsParts[1];
|
||||
const value = argsParts.length === 1 ? null : argsParts.slice(1).join("=");
|
||||
|
||||
if (argsParts[0].startsWith("--")) {
|
||||
const key = argsParts[0].substr(2);
|
||||
|
@ -169,9 +169,10 @@ export class Tokenizer {
|
|||
* etc.
|
||||
*
|
||||
* Joining the returned array with spaces in between will give back the input string, disregarding extra whitespaces
|
||||
* in between tokens. That is, no bytes are added, removed, or escaped in tokens.
|
||||
* in between tokens. That is, no bytes are added, removed, or escaped inside tokens.
|
||||
*
|
||||
* @param input the string to tokenize
|
||||
* @return the tokens
|
||||
*/
|
||||
tokenize(input: string): string[] {
|
||||
const tokens: string[] = [];
|
||||
|
|
|
@ -210,8 +210,8 @@ describe("input parser", () => {
|
|||
expect(parser.parseCommands("command -- -p")[0].options).to.not.have.own.property("-p");
|
||||
});
|
||||
|
||||
it("throws an error if multiple equals signs occur", () => {
|
||||
expect(() => parser.parseCommands("command -a=b=c")[0]).to.throw();
|
||||
it("allows option values with an equals sign", () => {
|
||||
expect(parser.parseCommands("command -a=b=c")[0].options["-a"]).to.equal("b=c");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue