mirror of
https://github.com/clap-rs/clap
synced 2024-12-05 02:29:12 +00:00
docs(tutorial): Don't cover 'author' as its not shown
This commit is contained in:
parent
42849cdf5f
commit
64ae186dfc
25 changed files with 22 additions and 25 deletions
|
@ -8,7 +8,7 @@ enum CargoCli {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct ExampleDeriveArgs {
|
struct ExampleDeriveArgs {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
manifest_path: Option<std::path::PathBuf>,
|
manifest_path: Option<std::path::PathBuf>,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use clap::Parser;
|
||||||
|
|
||||||
/// Simple program to greet a person
|
/// Simple program to greet a person
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Name of the person to greet
|
/// Name of the person to greet
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)] // requires `derive` feature
|
#[derive(Parser)] // requires `derive` feature
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(short = 'f')]
|
#[arg(short = 'f')]
|
||||||
eff: bool,
|
eff: bool,
|
||||||
|
|
|
@ -6,7 +6,6 @@ fn main() {
|
||||||
.version("5.2.1")
|
.version("5.2.1")
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.author("Pacman Development Team")
|
|
||||||
// Query subcommand
|
// Query subcommand
|
||||||
//
|
//
|
||||||
// Only a few of its arguments are implemented below.
|
// Only a few of its arguments are implemented below.
|
||||||
|
|
|
@ -3,7 +3,6 @@ use clap::{arg, Command};
|
||||||
fn main() {
|
fn main() {
|
||||||
let matches = Command::new("MyApp")
|
let matches = Command::new("MyApp")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.author("Kevin K. <kbknapp@gmail.com>")
|
|
||||||
.about("Does awesome things")
|
.about("Does awesome things")
|
||||||
.arg(arg!(--two <VALUE>).required(true))
|
.arg(arg!(--two <VALUE>).required(true))
|
||||||
.arg(arg!(--one <VALUE>).required(true))
|
.arg(arg!(--one <VALUE>).required(true))
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Optional name to operate on
|
/// Optional name to operate on
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
#[command(next_line_help = true)]
|
#[command(next_line_help = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
|
|
@ -2,7 +2,6 @@ use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "MyApp")]
|
#[command(name = "MyApp")]
|
||||||
#[command(author = "Kevin K. <kbknapp@gmail.com>")]
|
|
||||||
#[command(version = "1.0")]
|
#[command(version = "1.0")]
|
||||||
#[command(about = "Does awesome things", long_about = None)]
|
#[command(about = "Does awesome things", long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)] // Read from `Cargo.toml`
|
#[command(version, about, long_about = None)] // Read from `Cargo.toml`
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
two: String,
|
two: String,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||||
verbose: u8,
|
verbose: u8,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
name: Vec<String>,
|
name: Vec<String>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
name: Vec<String>,
|
name: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
#[command(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Args, Parser, Subcommand};
|
use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
#[command(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[arg(default_value_t = 2020)]
|
#[arg(default_value_t = 2020)]
|
||||||
port: u16,
|
port: u16,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// What mode to run the program in
|
/// What mode to run the program in
|
||||||
#[arg(value_enum)]
|
#[arg(value_enum)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
#[arg(value_parser = clap::value_parser!(u16).range(1..))]
|
#[arg(value_parser = clap::value_parser!(u16).range(1..))]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
#[arg(value_parser = port_in_range)]
|
#[arg(value_parser = port_in_range)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Args, Parser};
|
use clap::{Args, Parser};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
vers: Vers,
|
vers: Vers,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use clap::error::ErrorKind;
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::{CommandFactory, Parser};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// set version manually
|
/// set version manually
|
||||||
#[arg(long, value_name = "VER")]
|
#[arg(long, value_name = "VER")]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Network port to use
|
/// Network port to use
|
||||||
port: u16,
|
port: u16,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//!
|
//!
|
||||||
#![doc = include_str!("../../../examples/tutorial_derive/02_apps.md")]
|
#![doc = include_str!("../../../examples/tutorial_derive/02_apps.md")]
|
||||||
//!
|
//!
|
||||||
//! You can use [`#[command(author, version, about)]` attribute defaults][super#command-attributes] on the struct to fill these fields in from your `Cargo.toml` file.
|
//! You can use [`#[command(version, about)]` attribute defaults][super#command-attributes] on the struct to fill these fields in from your `Cargo.toml` file.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
#![doc = include_str!("../../../examples/tutorial_derive/02_crate.rs")]
|
#![doc = include_str!("../../../examples/tutorial_derive/02_crate.rs")]
|
||||||
|
|
Loading…
Reference in a new issue