@@ -14,7 +14,7 @@ use clap::Parser;
1414use maturin:: GenerateJsonSchemaOptions ;
1515#[ cfg( feature = "upload" ) ]
1616use maturin:: PublishOpt ;
17- use maturin:: { BuildOptions , DevelopOptions , TargetTriple } ;
17+ use maturin:: { BuildOptions , CargoOptions , DevelopOptions , PythonOptions , TargetTriple } ;
1818#[ cfg( feature = "scaffolding" ) ]
1919use maturin:: { GenerateProjectOptions , ci:: GenerateCI } ;
2020use std:: env;
@@ -163,6 +163,19 @@ enum Command {
163163 #[ arg( value_name = "FILE" ) ]
164164 files : Vec < PathBuf > ,
165165 } ,
166+ /// Autogenerate type stubs
167+ #[ command( name = "generate-stubs" ) ]
168+ GenerateStub {
169+ /// The directory to store the type stubs in
170+ #[ arg( short, long) ]
171+ out : PathBuf ,
172+ /// Python and bindings options
173+ #[ command( flatten) ]
174+ python : PythonOptions ,
175+ /// Cargo build options
176+ #[ command( flatten) ]
177+ cargo : CargoOptions ,
178+ } ,
166179 /// Backend for the PEP 517 integration. Not for human consumption
167180 ///
168181 /// The commands are meant to be called from the python PEP 517
@@ -254,6 +267,9 @@ fn run() -> Result<()> {
254267 Command :: GenerateCI ( generate_ci) => commands:: generate_ci ( generate_ci) ?,
255268 #[ cfg( feature = "upload" ) ]
256269 Command :: Upload { publish, files } => commands:: upload ( publish, files) ?,
270+ Command :: GenerateStub { out, python, cargo } => {
271+ commands:: generate_stubs:: generate_stubs ( out, python, cargo) ?
272+ }
257273 #[ cfg( feature = "cli-completion" ) ]
258274 Command :: Completions { shell } => {
259275 commands:: completions ( shell, & mut Opt :: command ( ) ) ;
0 commit comments