Giter Club home page Giter Club logo

lexure's People

Contributors

1computer1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lexure's Issues

Multiple values for an option

Allow multiple values in an option, e.g. --foo 1 --foo 2 --foo 3 would give 'foo' => ['1', '2', '3'] in the result,

Returning `null` vs throwing

Many parsing methods return null rather than throwing. I think throwing an error is nicer to write code for as a user and is closer to what Node.js does (ex. new URL('invalid') throws). Here I've rewritten the basic example from the readme the way it would be if it no longer returned null:

const input = '!hello world "cool stuff" --foo --bar=baz a b c';
const lexer = new lexure.Lexer(input)
    .setQuotes([
        ['"', '"'],
        ['“', '”']
    ]);

try {
    const res = lexer.lexCommand(s => s.startsWith('!') ? 1 : null);

    console.log(res);
} catch (error) {
    console.error('Bad input:', error);
}

If Lexure is having an error parsing that should be reflected in the code. This also has the added benefit of making return types cleaner since there's no more Whatever | null.
Interesting in hearing your thoughts on this.

Allow more convenient customizing of unordered argument matching

Right now, longStrategy and longShortStrategy are hardcoded to use the usual -- and = syntax.
It would be nice to support more styles, such as --flag: or \flag by allowing users to pass in their own prefix and separator.
Current way to do this is to simply copy paste those strategies and modify the regex.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.