mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
parent
5672bf9529
commit
ed987933cf
2 changed files with 5 additions and 9 deletions
|
@ -17,9 +17,9 @@ clap = "3"
|
||||||
```
|
```
|
||||||
|
|
||||||
And then, in your rust file:
|
And then, in your rust file:
|
||||||
```rust
|
```rust,no_run
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use clap::Parser;
|
use clap::{Parser, ValueHint};
|
||||||
|
|
||||||
/// A basic example
|
/// A basic example
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
|
@ -48,7 +48,7 @@ struct Opt {
|
||||||
// the long option will be translated by default to kebab case,
|
// the long option will be translated by default to kebab case,
|
||||||
// i.e. `--nb-cars`.
|
// i.e. `--nb-cars`.
|
||||||
/// Number of cars
|
/// Number of cars
|
||||||
#[clap(short = "c", long)]
|
#[clap(short = 'c', long)]
|
||||||
nb_cars: Option<i32>,
|
nb_cars: Option<i32>,
|
||||||
|
|
||||||
/// admin_level to consider
|
/// admin_level to consider
|
||||||
|
@ -67,7 +67,7 @@ fn main() {
|
||||||
```
|
```
|
||||||
|
|
||||||
Using this example:
|
Using this example:
|
||||||
```
|
```bash
|
||||||
$ ./basic
|
$ ./basic
|
||||||
error: The following required arguments were not provided:
|
error: The following required arguments were not provided:
|
||||||
--output <output>
|
--output <output>
|
||||||
|
|
|
@ -14,11 +14,7 @@
|
||||||
|
|
||||||
#![doc(html_logo_url = "https://clap.rs/images/media/clap.png")]
|
#![doc(html_logo_url = "https://clap.rs/images/media/clap.png")]
|
||||||
#![doc(html_root_url = "https://docs.rs/clap_derive/3.0.0-beta.5")]
|
#![doc(html_root_url = "https://docs.rs/clap_derive/3.0.0-beta.5")]
|
||||||
|
#![doc = include_str!("../README.md")]
|
||||||
//! This crate is custom derive for clap. It should not be used
|
|
||||||
//! directly. See [clap documentation](http://docs.rs/clap)
|
|
||||||
//! for the usage of `#[derive(Parser)]`.
|
|
||||||
|
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
Loading…
Reference in a new issue