Code Monkey home page Code Monkey logo

Comments (6)

DartBot avatar DartBot commented on June 1, 2024

<img src="https://avatars.githubusercontent.com/u/4865287?v=3" align="left" width="48" height="48"hspace="10"> Comment by lrhn


Added Pkg-Args, Area-Pkg, Triaged labels.

from args.

nex3 avatar nex3 commented on June 1, 2024

@hoylen Your example is ambiguous; there's no way for the parser to decide whether -32 is a value or a (potentially typoed) flag.

That said, there should be a way to pass this value; the parser should probably interpret a leading backslash in an argument value as an escape. This seems to be the standard among UNIX command-line programs. This could be interpreted as a breaking change, but it's only going to break the users of command-line apps who won't be able to add version constraints on args anyway. It's also quite minor, so I think it could be fixed in a patch release. @munificent, what do you think?

from args.

hoylen avatar hoylen commented on June 1, 2024

The use case is not ambiguous, since an option is specified using the addOption method and there is a different method for setting flags (addFlag). The argument parser expects to find an option argument after the "-t", so it should know not to treat "-32" as flag/option.

The implementation should follow the rules established by GNU getopt (and getopt_long), since that is what is familiar to developers and users. Certainly better than doing something that is inconsistent with known conventions. Otherwise, Dart command line programs will behave differently from non-Dart command line programs, and be confusing for users. The GNU getopt implementation has figured out how to treat the different situations (the above example was easy, since there is a space between the option and the option's argument, but the GNU getopt also has a convention for how to treat "-t3").

The GNU getopt is the defacto standard, since they invented the double-hyphen long arguments. So if Dart is to support them, it should follow the GNU getopt parsing rules exactly. Don't go about inventing new rules (e.g. backslash escaping) which only apply to Dart's argument parser.

from args.

nex3 avatar nex3 commented on June 1, 2024

All right, I buy that we should do the same thing as getopt_long here.

from args.

seaneagan avatar seaneagan commented on June 1, 2024

@nex3 is "-t-32" supported (without a space) ? I didn't see a test for it in the diff.

from args.

nex3 avatar nex3 commented on June 1, 2024

@seaneagan Yes. There's no test for that because it's not really ambiguous; there's no reason we'd even try to parse that as an option.

from args.

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.