Git Product home page Git Product logo

Comments (5)

benbrittain avatar benbrittain commented on September 27, 2024

There is not currently, I'd potentially be open to a PR depending on how it's implemented.

I'd suggest checking after parsing if it meets the conditions for now.

from argh.

Geobert avatar Geobert commented on September 27, 2024

Proposal

#[derive(FromArgs)]
/// MyCMD
struct Opt {
    #[argh(positional(1))] // expected number of items
    /// script files to run
    test_file: Vec<PathBuf>,
}

if minimum number of expected item > 0, do not print brackets.

I'm not very familiar with proc_macro yet, so I don't know if this is acceptable :)

EDIT: I'm checking after parsing for now, yes :)

EDIT2: even better? if not Option<_>, it is mandatory, regardless of the field kind

from argh.

trevarj avatar trevarj commented on September 27, 2024

I started hacking this type of syntax into the attribute macro, but it seems that the requested functionality is unclear.

Should inside the parenthesis be the exact expected number of values or the minimum number number of values expected?

I'm able to get the macro syntax to play nice, i.e positional(1) or falling back to just positional, but after that it gets way over my head. Time to learn!

from argh.

Geobert avatar Geobert commented on September 27, 2024

Good question, my first post speaks about "at least" and the 2nd post is "expected number of items". Is it possible to specify something like: =1 or >=1 or >1 for "exact number", minimum number, more than number?

from argh.

trevarj avatar trevarj commented on September 27, 2024

I didn't see that ability in my exploration. I only saw meta data capabilities for key value pairs which would allow positional=1 or a list type that would allow positional(1).

Ben Brittain or another maintainer would know much better than me.

from argh.

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.