Skip to content

Commit

Permalink
Merge pull request #812 from messense/clap-3.1
Browse files Browse the repository at this point in the history
Update to clap 3.1
  • Loading branch information
messense authored Feb 18, 2022
2 parents 9d7881d + 3a596c6 commit eec1822
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
63 changes: 32 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ console = "0.15.0"
minijinja = "0.13.0"
lddtree = "0.2.7"
cc = "1.0.72"
clap = { version = "3.0.13", features = ["derive", "env", "wrap_help"] }
clap_complete = "3.0.6"
clap_complete_fig = "3.0.2"
clap = { version = "3.1.0", features = ["derive", "env", "wrap_help"] }
clap_complete = "3.1.0"
clap_complete_fig = "3.1.0"
semver = "1.0.5"
# upload
configparser = { version = "3.0.0", optional = true }
Expand Down
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Run with --help for usage information
use anyhow::{bail, Context, Result};
use clap::{ArgEnum, IntoApp, Parser};
use clap::{ArgEnum, IntoApp, Parser, Subcommand};
use clap_complete::Generator;
use maturin::{
develop, init_project, new_project, write_dist_info, BridgeModel, BuildOptions,
Expand Down Expand Up @@ -97,7 +97,7 @@ enum Opt {
#[clap(
short = 'E',
long,
use_delimiter = true,
use_value_delimiter = true,
multiple_values = false,
multiple_occurrences = false
)]
Expand Down Expand Up @@ -158,7 +158,7 @@ enum Opt {
#[clap(subcommand)]
Pep517(Pep517Command),
/// Generate shell completions
#[clap(name = "completions", setting = clap::AppSettings::Hidden)]
#[clap(name = "completions", hide = true)]
Completions {
#[clap(name = "SHELL", parse(try_from_str))]
shell: Shell,
Expand All @@ -171,8 +171,8 @@ enum Opt {
/// Backend for the PEP 517 integration. Not for human consumption
///
/// The commands are meant to be called from the python PEP 517
#[derive(Debug, Parser)]
#[clap(name = "pep517", setting = clap::AppSettings::Hidden)]
#[derive(Debug, Subcommand)]
#[clap(name = "pep517", hide = true)]
enum Pep517Command {
/// The implementation of prepare_metadata_for_build_wheel
#[clap(name = "write-dist-info")]
Expand Down Expand Up @@ -427,12 +427,12 @@ fn run() -> Result<()> {
upload_ui(&files, &publish)?
}
Opt::Completions { shell } => {
let mut app = Opt::into_app();
let mut cmd = Opt::command();
match shell {
Shell::Fig => {
app.set_bin_name(env!("CARGO_BIN_NAME"));
cmd.set_bin_name(env!("CARGO_BIN_NAME"));
let fig = clap_complete_fig::Fig;
fig.generate(&app, &mut io::stdout());
fig.generate(&cmd, &mut io::stdout());
}
_ => {
let shell = match shell {
Expand All @@ -445,7 +445,7 @@ fn run() -> Result<()> {
};
clap_complete::generate(
shell,
&mut app,
&mut cmd,
env!("CARGO_BIN_NAME"),
&mut io::stdout(),
)
Expand Down
9 changes: 5 additions & 4 deletions src/zig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::target::Arch;
use crate::{BuildContext, PlatformTag};
use anyhow::{bail, Context, Result};
use clap::Subcommand;
use fs_err as fs;
use std::env;
#[cfg(target_family = "unix")]
Expand All @@ -16,18 +17,18 @@ use std::process::{self, Command};
use std::str;

/// Zig linker wrapper
#[derive(Debug, clap::Parser)]
#[clap(name = "zig", setting = clap::AppSettings::Hidden)]
#[derive(Debug, Subcommand)]
#[clap(name = "zig", hide = true)]
pub enum Zig {
/// `zig cc` wrapper
#[clap(name = "cc", setting = clap::AppSettings::TrailingVarArg)]
#[clap(name = "cc", trailing_var_arg = true)]
Cc {
/// `zig cc` arguments
#[clap(takes_value = true, multiple_values = true)]
args: Vec<String>,
},
/// `zig c++` wrapper
#[clap(name = "c++", setting = clap::AppSettings::TrailingVarArg)]
#[clap(name = "c++", trailing_var_arg = true)]
Cxx {
/// `zig c++` arguments
#[clap(takes_value = true, multiple_values = true)]
Expand Down

0 comments on commit eec1822

Please sign in to comment.