Skip to content

Commit

Permalink
Add a command to generate shell completions
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jul 10, 2021
1 parent 7f0dd70 commit 56a24b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (for the cli, not for the crate).

## Unreleased

* Add `maturin completions <shell>` command to generate shell completions in [#586](https://github.com/PyO3/maturin/pull/586)

## 0.11.0 - 2021-07-04

* Add support for reading metadata from [PEP 621](https://www.python.org/dev/peps/pep-0621/) project table in `pyproject.toml` in [#555](https://github.com/PyO3/maturin/pull/555)
Expand Down
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use maturin::{
Metadata21, PathWriter, PlatformTag, PyProjectToml, PythonInterpreter, Target,
};
use std::env;
use std::io;
use std::path::PathBuf;
use structopt::StructOpt;
#[cfg(feature = "upload")]
use {
maturin::{upload, Registry, UploadError},
reqwest::Url,
std::io,
};

/// Returns the password and a bool that states whether to ask for re-entering the password
Expand Down Expand Up @@ -283,6 +283,12 @@ enum Opt {
/// The commands are meant to be called from the python PEP 517
#[structopt(name = "pep517", setting = structopt::clap::AppSettings::Hidden)]
Pep517(Pep517Command),
/// Generate shell completions
#[structopt(name = "completions", setting = structopt::clap::AppSettings::Hidden)]
Completions {
#[structopt(name = "SHELL", parse(try_from_str))]
shell: structopt::clap::Shell,
},
}

/// Backend for the PEP 517 integration. Not for human consumption
Expand Down Expand Up @@ -608,6 +614,9 @@ fn run() -> Result<()> {

upload_ui(&files, &publish)?
}
Opt::Completions { shell } => {
Opt::clap().gen_completions_to(env!("CARGO_BIN_NAME"), shell, &mut io::stdout());
}
}

Ok(())
Expand Down

0 comments on commit 56a24b8

Please sign in to comment.