Skip to content

Instantly share code, notes, and snippets.

@zeddash
Last active May 20, 2020 15:57
Show Gist options
  • Select an option

  • Save zeddash/842ef7d76a9e6ad0a0c4c1c012ea6752 to your computer and use it in GitHub Desktop.

Select an option

Save zeddash/842ef7d76a9e6ad0a0c4c1c012ea6752 to your computer and use it in GitHub Desktop.

Revisions

  1. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -15,14 +15,14 @@ const servers = {

    const createPattern = arr => {
    arr = arr.map(x => x.replace(/([\?\*\|\^\$\-\\+{}\[\]()<>,.])/g, "\\$1"))
    return new RegExp(`(${arr.join("|")}|dolphin)`)
    return new RegExp(`^(${arr.join("|")}|dolphin)`)
    }

    const getPrefixes = n => {
    if(servers[n]) {
    return createPattern(servers[n])
    } else {
    return /(\-\-|\-d|dolphin)/
    return /^(\-\-|\-d|dolphin)/
    }
    }

  2. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ const servers = {

    const createPattern = arr => {
    arr = arr.map(x => x.replace(/([\?\*\|\^\$\-\\+{}\[\]()<>,.])/g, "\\$1"))
    return new Regex(`/${arr.join("|")}|dolphin/`)
    return new RegExp(`(${arr.join("|")}|dolphin)`)
    }

    const getPrefixes = n => {
  3. zeddash revised this gist May 20, 2020. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -106,7 +106,7 @@ const expectedOutput = [

    const parseCommands = (command, server) => {
    const prefixes = getPrefixes(server)
    if()
    //if()
    command.split(';').forEach(x => {
    x.trim()
    });
    @@ -115,4 +115,5 @@ const parseCommands = (command, server) => {
    commands.forEach((element) => {
    parseCommands(element, 0);
    });
    console.log()
    console.log(getPrefixes())
    console.log(getPrefixes(1000))
  4. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -102,7 +102,7 @@ const expectedOutput = [
    ]
    ];

    const parseCommand =
    //const parseCommand =

    const parseCommands = (command, server) => {
    const prefixes = getPrefixes(server)
    @@ -115,3 +115,4 @@ const parseCommands = (command, server) => {
    commands.forEach((element) => {
    parseCommands(element, 0);
    });
    console.log()
  5. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ const createPattern = arr => {

    const getPrefixes = n => {
    if(servers[n]) {
    return createPatternservers[n]
    return createPattern(servers[n])
    } else {
    return /(\-\-|\-d|dolphin)/
    }
  6. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -14,12 +14,13 @@ const servers = {
    }

    const createPattern = arr => {
    arr = arr.map(x => x.replace(/([\?\*\|\^\$\-\\+{}\[\]()<>,.])/g, "\\$1"))
    return new Regex(`/${arr.join("|")}|dolphin/`)
    }

    const getPrefixes = n => {
    if(servers[n]) {
    return servers[n]
    return createPatternservers[n]
    } else {
    return /(\-\-|\-d|dolphin)/
    }
  7. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ const servers = {
    }

    const createPattern = arr => {
    return new Regex()`arr.join("|")`
    return new Regex(`/${arr.join("|")}|dolphin/`)
    }

    const getPrefixes = n => {
  8. zeddash revised this gist May 20, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,9 @@ const servers = {
    1000: ["--"]
    }

    const createPattern =
    const createPattern = arr => {
    return new Regex()`arr.join("|")`
    }

    const getPrefixes = n => {
    if(servers[n]) {
  9. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ const getPrefixes = n => {
    if(servers[n]) {
    return servers[n]
    } else {
    return ["--", "-d"]
    return /(\-\-|\-d|dolphin)/
    }
    }

  10. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,8 @@ const servers = {
    1000: ["--"]
    }

    const createPattern =

    const getPrefixes = n => {
    if(servers[n]) {
    return servers[n]
  11. zeddash revised this gist May 20, 2020. No changes.
  12. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ const parseCommands = (command, server) => {
    const prefixes = getPrefixes(server)
    if()
    command.split(';').forEach(x => {

    x.trim()
    });
    };

  13. zeddash revised this gist May 20, 2020. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -97,14 +97,16 @@ const expectedOutput = [
    ]
    ];

    const parseCommand = (command, server) => {
    const prefixes = getPrefixes
    const parseCommand =

    const parseCommands = (command, server) => {
    const prefixes = getPrefixes(server)
    if()
    command.split(';').forEach(x => {

    });
    };

    commands.forEach((element) => {
    parseCommand(element, 0);
    parseCommands(element, 0);
    });
  14. zeddash revised this gist May 20, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -97,14 +97,14 @@ const expectedOutput = [
    ]
    ];

    const parseCommand = (command) => {
    //const commands = []
    const parseCommand = (command, server) => {
    const prefixes = getPrefixes
    if()
    command.split(';').forEach(x => {

    });
    };

    commands.forEach((element) => {
    parseCommand(element);
    parseCommand(element, 0);
    });
  15. zeddash revised this gist May 20, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,11 @@ const servers = {
    }

    const getPrefixes = n => {
    if(servers.)
    if(servers[n]) {
    return servers[n]
    } else {
    return ["--", "-d"]
    }
    }

    const commandSchema = {
  16. zeddash revised this gist May 20, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -9,10 +9,12 @@ const commands = [
    "--command value; -- secondcommand value2"
    ];

    const servers
    const servers = {
    1000: ["--"]
    }

    const getPrefixes = n => {

    if(servers.)
    }

    const commandSchema = {
  17. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ const commands = [
    "--command value; -- secondcommand value2"
    ];

    const servers

    const getPrefixes = n => {

    }
  18. zeddash revised this gist May 20, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,10 @@ const commands = [
    "--command value; -- secondcommand value2"
    ];

    const getPrefixes = n => {

    }

    const commandSchema = {
    command: {
    o: "option",
  19. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -87,6 +87,7 @@ const expectedOutput = [

    const parseCommand = (command) => {
    //const commands = []
    if()
    command.split(';').forEach(x => {

    });
  20. zeddash revised this gist May 20, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -87,7 +87,9 @@ const expectedOutput = [

    const parseCommand = (command) => {
    //const commands = []

    command.split(';').forEach(x => {

    });
    };

    commands.forEach((element) => {
  21. zeddash revised this gist May 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -86,7 +86,7 @@ const expectedOutput = [
    ];

    const parseCommand = (command) => {
    const commands = []
    //const commands = []

    };

  22. zeddash revised this gist May 20, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -86,7 +86,8 @@ const expectedOutput = [
    ];

    const parseCommand = (command) => {
    console.log(command.split(";"));
    const commands = []

    };

    commands.forEach((element) => {
  23. zeddash revised this gist May 20, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,11 @@ const expectedOutput = [
    {
    command: "command",
    value: "value",
    },
    },
    {
    command: "secondcommand",
    value: "value2",
    }
    ]
    ];

  24. zeddash revised this gist May 20, 2020. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,8 @@ const commands = [
    "-- command --no-option",
    "-- command value --option",
    "-dcommand value --option 5 -v",
    "dolphin command value --option true -v yes",
    "dolphin command value --option true -v yes",
    "--command value; -- secondcommand value2"
    ];

    const commandSchema = {
    @@ -72,6 +73,12 @@ const expectedOutput = [
    },
    },
    ],
    [
    {
    command: "command",
    value: "value",
    },
    ]
    ];

    const parseCommand = (command) => {
  25. zeddash revised this gist May 20, 2020. 1 changed file with 76 additions and 62 deletions.
    138 changes: 76 additions & 62 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -1,69 +1,83 @@
    const commands = [
    "--command",
    "--command value",
    "-- command --option",
    "-- command --no-option",
    "-- command value --option",
    "-dcommand value --option 5 -v",
    "dolphin command value --option true -v yes"
    ]
    "--command",
    "--command value",
    "-- command --option",
    "-- command --no-option",
    "-- command value --option",
    "-dcommand value --option 5 -v",
    "dolphin command value --option true -v yes",
    ];

    const commandSchema = {
    command: {
    o: "option",
    v: "value"
    }
    }
    command: {
    o: "option",
    v: "value",
    },
    };

    const expectedOutput = [
    [{
    command: "command"
    }],
    [{
    command: "command",
    value: "value"
    }],
    [{
    command: "command",
    flags: {
    option:true
    }
    }],
    [{
    command: "command",
    flags: {
    option:false
    }
    }],
    [{
    command: "command",
    value: "value",
    flags: {
    option:true
    }
    }],
    [{
    command: "command",
    value: "value",
    flags: {
    option:5,
    value: true
    }
    },
    {
    command: "command",
    value: "value",
    flags: {
    option:true,
    value: "yes"
    }
    }
    ]
    [
    {
    command: "command",
    },
    ],
    [
    {
    command: "command",
    value: "value",
    },
    ],
    [
    {
    command: "command",
    flags: {
    option: true,
    },
    },
    ],
    [
    {
    command: "command",
    flags: {
    option: false,
    },
    },
    ],
    [
    {
    command: "command",
    value: "value",
    flags: {
    option: true,
    },
    },
    ],
    [
    {
    command: "command",
    value: "value",
    flags: {
    option: 5,
    value: true,
    },
    },
    ],
    [
    {
    command: "command",
    value: "value",
    flags: {
    option: true,
    value: "yes",
    },
    },
    ],
    ];

    const parseCommand = command => {
    console.log(command.split(';'))
    }
    const parseCommand = (command) => {
    console.log(command.split(";"));
    };

    commands.forEach(element => {
    parseCommand(element)
    });
    commands.forEach((element) => {
    parseCommand(element);
    });
  26. zeddash revised this gist May 20, 2020. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -16,33 +16,33 @@ const commandSchema = {
    }

    const expectedOutput = [
    {
    [{
    command: "command"
    },
    {
    }],
    [{
    command: "command",
    value: "value"
    },
    {
    }],
    [{
    command: "command",
    flags: {
    option:true
    }
    },
    {
    }],
    [{
    command: "command",
    flags: {
    option:false
    }
    },
    {
    }],
    [{
    command: "command",
    value: "value",
    flags: {
    option:true
    }
    },
    {
    }],
    [{
    command: "command",
    value: "value",
    flags: {
    @@ -64,6 +64,6 @@ const parseCommand = command => {
    console.log(command.split(';'))
    }

    commands..forEach(element => {

    commands.forEach(element => {
    parseCommand(element)
    });
  27. zeddash revised this gist May 20, 2020. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -61,5 +61,9 @@ const expectedOutput = [
    ]

    const parseCommand = command => {
    command
    }
    console.log(command.split(';'))
    }

    commands..forEach(element => {

    });
  28. zeddash revised this gist May 20, 2020. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -33,30 +33,30 @@ const expectedOutput = [
    command: "command",
    flags: {
    option:false
    ]
    }
    },
    {
    command: "command",
    value: "value",
    flags: {
    option:true
    ]
    }
    },
    {
    command: "command",
    value: "value",
    flags: {
    option:5,
    value: true
    ]
    }
    },
    {
    command: "command",
    value: "value",
    flags: {
    option:true,
    value: "yes"
    ]
    }
    }
    ]

  29. zeddash revised this gist May 20, 2020. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -25,35 +25,35 @@ const expectedOutput = [
    },
    {
    command: "command",
    flags: [
    flags: {
    option:true
    ]
    }
    },
    {
    command: "command",
    flags: [
    flags: {
    option:false
    ]
    },
    {
    command: "command",
    value: "value",
    flags: [
    flags: {
    option:true
    ]
    },
    {
    command: "command",
    value: "value",
    flags: [
    flags: {
    option:5,
    value: true
    ]
    },
    {
    command: "command",
    value: "value",
    flags: [
    flags: {
    option:true,
    value: "yes"
    ]
  30. zeddash revised this gist May 20, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,6 @@ const expectedOutput = [
    }
    ]

    const par
    const parseCommand = command => {
    command
    }