Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a command to generate shell completions #586

Merged
merged 1 commit into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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