Comments (5)
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.
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.
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.
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.
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)
- 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.