Git Product home page Git Product logo

Comments (4)

xenomachina avatar xenomachina commented on May 29, 2024

Yeah, positionalList is not intended to be associated with an option, so it won't do what you're trying to do here.

There is a way to do what you want using the internal option method. I almost made this method public, but ended up making it internal before the initial release, as its API is kind of ugly and error-prone, and I didn't want to paint myself into a corner by making it public.

I've also been considering cranking down its power a bit before making it public. Most arg parsing APIs have essentially 3 kinds of options: 0-arg, 1-arg, and 0/1-args (aka non-greedy 1-arg -- see #8 ). Right now options actually lets an option consume an arbitrary number of arguments, and decide to stop based on the argument values (with a look ahead of 1), even though none of the public helpers actually use this ability beyond consuming a single argument.

One idea I've had for changing it to be less error-prone, while still exposing more power than is currently available, is to make the user (of options) specify a fixed argument count. Then for your case you'd state that it takes 2-arguments. (I'd also have to special-case the 0/1 non-greedy case.)

In the meantime, would something like a "putting" method that works like adding but consumes 2 (instead of 1) args and puts the key/value pairs into a Map be good enough for your immediate needs? That would be pretty easy to add, and I think would probably be generally useful.

from kotlin-argparser.

xenomachina avatar xenomachina commented on May 29, 2024

I'm thinking that I'm going to change option to take an argument count (or possibly an argument name list), and make it public. I'm not going to have a chance to work on this for the next week or so, though.

from kotlin-argparser.

JakeWharton avatar JakeWharton commented on May 29, 2024

Sorry I've been busy and haven't had a chance to consider either putting or take a look at optional. I'm currently doing key=value and adding which works, so anything that lets me do the two argument things after a flag is excellent.

from kotlin-argparser.

xenomachina avatar xenomachina commented on May 29, 2024

Version 2.0.0 (just released) makes this possible. I've even added an example in the README (it's also in the tests). Search for "putting" in the README.

from kotlin-argparser.

Related Issues (20)

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.