Comments (4)
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.
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.
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.
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)
- add an attribute on option argument to let `from_str_fn` can return `Vec<T>` or `Option<T>` as-is HOT 7
- how skip a field like #[serde(skip)] HOT 2
- Is it possible to get a `TopLevelCommand`'s `FieldAttrs` with the current exposed API?
- positional arguments made on field with reserved named (ref_) keep the trailing _ in help text
- Negative switches
- Subcommand with no additional arguments? HOT 1
- Impossible to include angle brackets in help text in a way that satisfies argh and rustdoc
- Change `FromArgs::from_args` to accept `AsRef<str>`
- Support something like --helpfull which displays help for all subcommands HOT 2
- `#[argh(description = "...")]` only supports literal HOT 3
- Single dash is parsed as unrecognized argument HOT 1
- Disable automatically generated help message
- mutual exclusive options/switches
- don't work as a cargo-subcommand
- Any ability to specify 'raw' greedy args or pass-through?
- Consider making serde dependency optional (as a feature) HOT 1
- Inconsistent help-related behavior around subcommands
- Document `arg_name` attribute
- Unhelpfully-aimed error-messages on subcommands
- Positional arguments fail with negative numbers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argh.