Merge pull request #5317 from epage/author

docs: Adjust how we approach `author`
This commit is contained in:
Ed Page 2024-01-17 09:06:10 -06:00 committed by GitHub
commit ef45f2d4e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 23 additions and 25 deletions

View file

@ -8,7 +8,7 @@ enum CargoCli {
}
#[derive(clap::Args)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct ExampleDeriveArgs {
#[arg(long)]
manifest_path: Option<std::path::PathBuf>,

View file

@ -2,7 +2,7 @@ use clap::Parser;
/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
#[arg(short, long)]

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)] // requires `derive` feature
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short = 'f')]
eff: bool,

View file

@ -6,7 +6,6 @@ fn main() {
.version("5.2.1")
.subcommand_required(true)
.arg_required_else_help(true)
.author("Pacman Development Team")
// Query subcommand
//
// Only a few of its arguments are implemented below.

View file

@ -3,7 +3,6 @@ use clap::{arg, Command};
fn main() {
let matches = Command::new("MyApp")
.version("1.0")
.author("Kevin K. <kbknapp@gmail.com>")
.about("Does awesome things")
.arg(arg!(--two <VALUE>).required(true))
.arg(arg!(--one <VALUE>).required(true))

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// Optional name to operate on
name: Option<String>,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
#[command(next_line_help = true)]
struct Cli {
#[arg(long)]

View file

@ -2,7 +2,6 @@ use clap::Parser;
#[derive(Parser)]
#[command(name = "MyApp")]
#[command(author = "Kevin K. <kbknapp@gmail.com>")]
#[command(version = "1.0")]
#[command(about = "Does awesome things", long_about = None)]
struct Cli {

View file

@ -1,7 +1,7 @@
use clap::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 {
#[arg(long)]
two: String,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short, long)]
verbose: bool,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short, long)]
name: Option<String>,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short, long)]
name: Vec<String>,

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
name: Option<String>,
}

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
name: Vec<String>,
}

View file

@ -1,7 +1,7 @@
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]

View file

@ -1,7 +1,7 @@
use clap::{Args, Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(default_value_t = 2020)]
port: u16,

View file

@ -1,7 +1,7 @@
use clap::{Parser, ValueEnum};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// What mode to run the program in
#[arg(value_enum)]

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// Network port to use
#[arg(value_parser = clap::value_parser!(u16).range(1..))]

View file

@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// Network port to use
#[arg(value_parser = port_in_range)]

View file

@ -1,7 +1,7 @@
use clap::{Args, Parser};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
#[command(flatten)]
vers: Vers,

View file

@ -2,7 +2,7 @@ use clap::error::ErrorKind;
use clap::{CommandFactory, Parser};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// set version manually
#[arg(long, value_name = "VER")]

View file

@ -1,7 +1,7 @@
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(version, about, long_about = None)]
struct Cli {
/// Network port to use
port: u16,

View file

@ -8,7 +8,7 @@
//!
#![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
#![doc = include_str!("../../../examples/tutorial_derive/02_crate.rs")]

View file

@ -148,6 +148,7 @@
//! - `author [= <expr>]`: [`Command::author`][crate::Command::author]
//! - When not present: no author set
//! - Without `<expr>`: defaults to [crate `authors`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field)
//! - **NOTE:** A custom [`help_template`][crate::Command::help_template] is needed for author to show up.
//! - `about [= <expr>]`: [`Command::about`][crate::Command::about]
//! - When not present: [Doc comment summary](#doc-comments)
//! - Without `<expr>`: [crate `description`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-description-field) ([`Parser`][crate::Parser] container)