Giter Site home page Giter Site logo

Comments (4)

benbrittain avatar benbrittain commented on May 22, 2024 3

This library is currently used most widely through build systems that are not Cargo based. I don't think that cargo package version is always guaranteed to match the version surfaced to users either. It's pretty trivial to add this flag yourself, so for now I'd like to hold off on this feature request.

from argh.

suluke avatar suluke commented on May 22, 2024 2

FWIW I didn't find it that trivial to add a --version flag in case one has (otherwise) required options. But I came up with a solution here: https://gist.github.com/suluke/e0c672492126be0a4f3b4f0e1115d77c
Just replace argh::from_env with this module's argh_cargo::from_env. Since it more or less just wraps argh::from_env internally the integration should be clean-ish. The way the help text is extended is obviously a bit naive, but so is the current help text formatting in general IIUIC looking at https://github.com/google/argh/blob/master/argh_shared/src/lib.rs#L18. If this is something anyone would like to see upstreamed I'd be happy to create a PR.

from argh.

homeworkprod avatar homeworkprod commented on May 22, 2024

I agree that it's not that trivial.

Given a program that requires positional arguments, one could not simply add a --version switch and just print the version string because myprogram --version is aborted early with "Required positional arguments not provided: […]`.

Regarding CARGO_PKG_VERSION: How about defaulting to its value while providing an optional way to override it?

from argh.

SamuelMarks avatar SamuelMarks commented on May 22, 2024

Thanks @suluke that's useful. Would be great to see this integrated into the core library, with @homeworkprod's suggestion of CARGO_PKG_VERSION being just the default.

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.