Coder Social home page Coder Social logo

janet-kargs's Introduction

Janet Keyword Args (KArgs)

Kargs aim to make cli arguments function like Janet arguments. This follows a few simple rules.

  1. If we're not expecting a value, we try to parse a flag.
  2. A flag is defined as either a short flag or a long flag. A short flag can be -a or -abcd (this becomes an :abcd keyword, for use as flags). A long flag can be --abcd=value (where value is parsed as in 3) or --abcd (in which case the value is expected to be the next argument).
  3. If a flag is matched, flag semantics (as above) take over. Otherwise, or if we expect a value, we parse it using the Janet parser. If the parser outputs a symbol or fails to parse the value, we turn it into an as-is string.

And that's it. Have fun!

Note that this library is not stable, I reserve the right to change it whenever until 1.0.0 is tagged. This is because I'm going to pull a hehecat and use it in production to see if it feels right or not.

Bugs

Technically, I use parse and not parse-all. I probably should use parse-all and also check for length. I don't care though. Test condition: "1 hi" should result in "1 hi" but results in 1.

janet-kargs's People

Contributors

cosmictoast avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.