Repository: clap-rs/clap
Pull request #3236 (2021-12-31 19:21:05)

fix(complete): Better organize the API


Patch:
diff --git a/clap_complete/examples/bash_completion.rs b/clap_complete/examples/bash_completion.rs
index 8153fde6..57c060cc 100644
--- a/clap_complete/examples/bash_completion.rs
+++ b/clap_complete/examples/bash_completion.rs
@@ -1,5 +1,5 @@
 use clap::App;
-use clap_complete::{generate, generators::Bash};
+use clap_complete::{generate, shells::Bash};
 use std::io;
 
 fn main() {
diff --git a/clap_complete/src/generator/mod.rs b/clap_complete/src/generator/mod.rs
new file mode 100644
index 00000000..ef8e2b3e
--- /dev/null
+++ b/clap_complete/src/generator/mod.rs
@@ -0,0 +1,234 @@
+//! Shell completion machinery
+
+pub mod utils;
+
+use std::ffi::OsString;
+use std::fs::File;
+use std::io::Error;
+use std::io::Write;
+use std::path::PathBuf;
+
+use clap::App;
+
+/// Generator trait which can be used to write generators
+pub trait Generator {
+    /// Returns the file name that is created when this generator is called during compile time.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// # use std::io::Write;
+    /// # use clap::App;
+    /// use clap_complete::Generator;
+    ///
+    /// pub struct Fish;
+    ///
+    /// impl Generator for Fish {
+    /// #   fn generate(&self, app: &App, buf: &mut dyn Write) {}
+    ///     fn file_name(&self, name: &str) -> String {
+    ///         format!("{}.fish", name)
+    ///     }
+    /// }
+    /// ```
+    fn file_name(&self, name: &str) -> String;
+
+    /// Generates output out of [`clap::App`](App).
+    ///
+    /// # Examples
+    ///
+    /// The following example generator displays the [`clap::App`](App)
+    /// as if it is printed using [`std::println`].
+    ///
+    /// ```
+    /// use std::{io::Write, fmt::write};
+    /// use clap::App;
+    /// use clap_complete::Generator;
+    ///
+    /// pub struct ClapDebug;
+    ///
+    /// impl Generator for ClapDebug {
+    ///     fn generate(&self, app: &App, buf: &mut dyn Write) {
+    ///         write!(buf, "{}", app).unwrap();
+    ///     }
+    /// #   fn file_name(&self, name: &str) -> String {
+    /// #    name.into()
+    /// #   }
+    /// }
+    /// ```
+    fn generate(&self, app: &App, buf: &mut dyn Write);
+}
+
+/// Generate a completions file for a specified shell at compile-time.
+///
+/// **NOTE:** to generate the file at compile time you must use a `build.rs` "Build Script" or a
+/// [`cargo-xtask`](https://github.com/matklad/cargo-xtask)
+///
+/// # Examples
+///
+/// The following example generates a bash completion script via a `build.rs` script. In this
+/// simple example, we'll demo a very small application with only a single subcommand and two
+/// args. Real applications could be many multiple levels deep in subcommands, and have tens or
+/// potentially hundreds of arguments.
+///
+/// First, it helps if we separate out our `App` definition into a separate file. Whether you
+/// do this as a function, or bare App definition is a matter of personal preference.
+///
+/// ```
+/// // src/cli.rs
+///
+/// use clap::{App, Arg};
+///
+/// pub fn build_cli() -> App<'static> {
+///     App::new("compl")
+///         .about("Tests completions")
+///         .arg(Arg::new("file")
+///             .help("some input file"))
+///         .subcommand(App::new("test")
+///             .about("tests things")
+///             .arg(Arg::new("case")
+///                 .long("case")
+///                 .takes_value(true)
+///                 .help("the case to test")))
+/// }
+/// ```
+///
+/// In our regular code, we can simply call this `build_cli()` function, then call
+/// `get_matches()`, or any of the other normal methods directly after. For example:
+///
+/// ```ignore
+/// // src/main.rs
+///
+/// mod cli;
+///
+/// fn main() {
+///     let _m = cli::build_cli().get_matches();
+///
+///     // normal logic continues...
+/// }
+/// ```
+///
+/// Next, we set up our `Cargo.toml` to use a `build.rs` build script.
+///
+/// ```toml
+/// # Cargo.toml
+/// build = "build.rs"
+///
+/// [dependencies]
+/// clap = "*"
+///
+/// [build-dependencies]
+/// clap = "*"
+/// clap_complete = "*"
+/// ```
+///
+/// Next, we place a `build.rs` in our project root.
+///
+/// ```ignore
+/// use clap_complete::{generate_to, generators::Bash};
+/// use std::env;
+/// use std::io::Error;
+///
+/// include!("src/cli.rs");
+///
+/// fn main() -> Result<(), Error> {
+///     let outdir = match env::var_os("OUT_DIR") {
+///         None => return Ok(()),
+///         Some(outdir) => outdir,
+///     };
+///
+///     let mut app = build_cli();
+///     let path = generate_to(
+///         Bash,
+///         &mut app, // We need to specify what generator to use
+///         "myapp",  // We need to specify the bin name manually
+///         outdir,   // We need to specify where to write to
+///     )?;
+///
+///     println!("cargo:warning=completion file is generated: {:?}", path);
+///
+///     Ok(())
+/// }
+/// ```
+///
+/// Now, once we compile there will be a `{bin_name}.bash` file in the directory.
+/// Assuming we compiled with debug mode, it would be somewhere similar to
+/// `<project>/target/debug/build/myapp-<hash>/out/myapp.bash`.
+///
+/// **NOTE:** Please look at the individual [shells][crate::shells]
+/// to see the name of the files generated.
+pub fn generate_to<G, S, T>(
+    gen: G,
+    app: &mut clap::App,
+    bin_name: S,
+    out_dir: T,
+) -> Result<PathBuf, Error>
+where
+    G: Generator,
+    S: Into<String>,
+    T: Into<OsString>,
+{
+    app.set_bin_name(bin_name);
+
+    let out_dir = PathBuf::from(out_dir.into());
+    let file_name = gen.file_name(app.get_bin_name().unwrap());
+
+    let path = out_dir.join(file_name);
+    let mut file = File::create(&path)?;
+
+    _generate::<G, S>(gen, app, &mut file);
+    Ok(path)
+}
+
+/// Generate a completions file for a specified shell at runtime.
+///
+/// Until `cargo install` can install extra files like a completion script, this may be
+/// used e.g. in a command that outputs the contents of the completion script, to be
+/// redirected into a file by the user.
+///
+/// # Examples
+///
+/// Assuming a separate `cli.rs` like the [example above](generate_to()),
+/// we can let users generate a completion script using a command:
+///
+/// ```ignore
+/// // src/main.rs
+///
+/// mod cli;
+/// use std::io;
+/// use clap_complete::{generate, generators::Bash};
+///
+/// fn main() {
+///     let matches = cli::build_cli().get_matches();
+///
+///     if matches.is_present("generate-bash-completions") {
+///         generate(Bash, &mut cli::build_cli(), "myapp", &mut io::stdout());
+///     }
+///
+///     // normal logic continues...
+/// }
+///
+/// ```
+///
+/// Usage:
+///
+/// ```shell
+/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
+/// ```
+pub fn generate<G, S>(gen: G, app: &mut clap::App, bin_name: S, buf: &mut dyn Write)
+where
+    G: Generator,
+    S: Into<String>,
+{
+    app.set_bin_name(bin_name);
+    _generate::<G, S>(gen, app, buf)
+}
+
+fn _generate<G, S>(gen: G, app: &mut clap::App, buf: &mut dyn Write)
+where
+    G: Generator,
+    S: Into<String>,
+{
+    app._build_all();
+
+    gen.generate(app, buf)
+}
diff --git a/clap_complete/src/utils.rs b/clap_complete/src/generator/utils.rs
similarity index 99%
rename from clap_complete/src/utils.rs
rename to clap_complete/src/generator/utils.rs
index ba12a37d..a1eda6af 100644
--- a/clap_complete/src/utils.rs
+++ b/clap_complete/src/generator/utils.rs
@@ -1,3 +1,5 @@
+//! Helpers for writing generators
+
 use clap::{App, Arg, ArgSettings};
 
 /// Gets all subcommands including child subcommands in the form of `("name", "bin_name")`.
diff --git a/clap_complete/src/generators/mod.rs b/clap_complete/src/generators/mod.rs
deleted file mode 100644
index 12359019..00000000
--- a/clap_complete/src/generators/mod.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-mod shells;
-
-// Std
-use std::io::Write;
-
-// Internal
-use clap::App;
-pub use shells::*;
-
-/// Generator trait which can be used to write generators
-pub trait Generator {
-    /// Returns the file name that is created when this generator is called during compile time.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// # use std::io::Write;
-    /// # use clap::App;
-    /// use clap_complete::Generator;
-    ///
-    /// pub struct Fish;
-    ///
-    /// impl Generator for Fish {
-    /// #   fn generate(&self, app: &App, buf: &mut dyn Write) {}
-    ///     fn file_name(&self, name: &str) -> String {
-    ///         format!("{}.fish", name)
-    ///     }
-    /// }
-    /// ```
-    fn file_name(&self, name: &str) -> String;
-
-    /// Generates output out of [`clap::App`](App).
-    ///
-    /// # Examples
-    ///
-    /// The following example generator displays the [`clap::App`](App)
-    /// as if it is printed using [`std::println`].
-    ///
-    /// ```
-    /// use std::{io::Write, fmt::write};
-    /// use clap::App;
-    /// use clap_complete::Generator;
-    ///
-    /// pub struct ClapDebug;
-    ///
-    /// impl Generator for ClapDebug {
-    ///     fn generate(&self, app: &App, buf: &mut dyn Write) {
-    ///         write!(buf, "{}", app).unwrap();
-    ///     }
-    /// #   fn file_name(&self, name: &str) -> String {
-    /// #    name.into()
-    /// #   }
-    /// }
-    /// ```
-    fn generate(&self, app: &App, buf: &mut dyn Write);
-}
diff --git a/clap_complete/src/lib.rs b/clap_complete/src/lib.rs
index c27ec31e..a349efd9 100644
--- a/clap_complete/src/lib.rs
+++ b/clap_complete/src/lib.rs
@@ -61,195 +61,10 @@ const INTERNAL_ERROR_MSG: &str = "Fatal internal error. Please consider filing a
 #[allow(missing_docs)]
 mod macros;
 
-/// Contains some popular generators
-pub mod generators;
-/// Contains supported shells for auto-completion scripts
-mod shell;
-/// Helpers for writing generators
-pub mod utils;
+pub mod generator;
+pub mod shells;
 
-use std::ffi::OsString;
-use std::fs::File;
-use std::io::Error;
-use std::io::Write;
-use std::path::PathBuf;
-
-#[doc(inline)]
-pub use generators::Generator;
-#[doc(inline)]
-pub use shell::Shell;
-
-/// Generate a completions file for a specified shell at compile-time.
-///
-/// **NOTE:** to generate the file at compile time you must use a `build.rs` "Build Script" or a
-/// [`cargo-xtask`](https://github.com/matklad/cargo-xtask)
-///
-/// # Examples
-///
-/// The following example generates a bash completion script via a `build.rs` script. In this
-/// simple example, we'll demo a very small application with only a single subcommand and two
-/// args. Real applications could be many multiple levels deep in subcommands, and have tens or
-/// potentially hundreds of arguments.
-///
-/// First, it helps if we separate out our `App` definition into a separate file. Whether you
-/// do this as a function, or bare App definition is a matter of personal preference.
-///
-/// ```
-/// // src/cli.rs
-///
-/// use clap::{App, Arg};
-///
-/// pub fn build_cli() -> App<'static> {
-///     App::new("compl")
-///         .about("Tests completions")
-///         .arg(Arg::new("file")
-///             .help("some input file"))
-///         .subcommand(App::new("test")
-///             .about("tests things")
-///             .arg(Arg::new("case")
-///                 .long("case")
-///                 .takes_value(true)
-///                 .help("the case to test")))
-/// }
-/// ```
-///
-/// In our regular code, we can simply call this `build_cli()` function, then call
-/// `get_matches()`, or any of the other normal methods directly after. For example:
-///
-/// ```ignore
-/// // src/main.rs
-///
-/// mod cli;
-///
-/// fn main() {
-///     let _m = cli::build_cli().get_matches();
-///
-///     // normal logic continues...
-/// }
-/// ```
-///
-/// Next, we set up our `Cargo.toml` to use a `build.rs` build script.
-///
-/// ```toml
-/// # Cargo.toml
-/// build = "build.rs"
-///
-/// [dependencies]
-/// clap = "*"
-///
-/// [build-dependencies]
-/// clap = "*"
-/// clap_complete = "*"
-/// ```
-///
-/// Next, we place a `build.rs` in our project root.
-///
-/// ```ignore
-/// use clap_complete::{generate_to, generators::Bash};
-/// use std::env;
-/// use std::io::Error;
-///
-/// include!("src/cli.rs");
-///
-/// fn main() -> Result<(), Error> {
-///     let outdir = match env::var_os("OUT_DIR") {
-///         None => return Ok(()),
-///         Some(outdir) => outdir,
-///     };
-///
-///     let mut app = build_cli();
-///     let path = generate_to(
-///         Bash,
-///         &mut app, // We need to specify what generator to use
-///         "myapp",  // We need to specify the bin name manually
-///         outdir,   // We need to specify where to write to
-///     )?;
-///
-///     println!("cargo:warning=completion file is generated: {:?}", path);
-///
-///     Ok(())
-/// }
-/// ```
-///
-/// Now, once we compile there will be a `{bin_name}.bash` file in the directory.
-/// Assuming we compiled with debug mode, it would be somewhere similar to
-/// `<project>/target/debug/build/myapp-<hash>/out/myapp.bash`.
-///
-/// **NOTE:** Please look at the individual [generators]
-/// to see the name of the files generated.
-pub fn generate_to<G, S, T>(
-    gen: G,
-    app: &mut clap::App,
-    bin_name: S,
-    out_dir: T,
-) -> Result<PathBuf, Error>
-where
-    G: Generator,
-    S: Into<String>,
-    T: Into<OsString>,
-{
-    app.set_bin_name(bin_name);
-
-    let out_dir = PathBuf::from(out_dir.into());
-    let file_name = gen.file_name(app.get_bin_name().unwrap());
-
-    let path = out_dir.join(file_name);
-    let mut file = File::create(&path)?;
-
-    _generate::<G, S>(gen, app, &mut file);
-    Ok(path)
-}
-
-/// Generate a completions file for a specified shell at runtime.
-///
-/// Until `cargo install` can install extra files like a completion script, this may be
-/// used e.g. in a command that outputs the contents of the completion script, to be
-/// redirected into a file by the user.
-///
-/// # Examples
-///
-/// Assuming a separate `cli.rs` like the [example above](generate_to()),
-/// we can let users generate a completion script using a command:
-///
-/// ```ignore
-/// // src/main.rs
-///
-/// mod cli;
-/// use std::io;
-/// use clap_complete::{generate, generators::Bash};
-///
-/// fn main() {
-///     let matches = cli::build_cli().get_matches();
-///
-///     if matches.is_present("generate-bash-completions") {
-///         generate(Bash, &mut cli::build_cli(), "myapp", &mut io::stdout());
-///     }
-///
-///     // normal logic continues...
-/// }
-///
-/// ```
-///
-/// Usage:
-///
-/// ```shell
-/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
-/// ```
-pub fn generate<G, S>(gen: G, app: &mut clap::App, bin_name: S, buf: &mut dyn Write)
-where
-    G: Generator,
-    S: Into<String>,
-{
-    app.set_bin_name(bin_name);
-    _generate::<G, S>(gen, app, buf)
-}
-
-fn _generate<G, S>(gen: G, app: &mut clap::App, buf: &mut dyn Write)
-where
-    G: Generator,
-    S: Into<String>,
-{
-    app._build_all();
-
-    gen.generate(app, buf)
-}
+pub use generator::generate;
+pub use generator::generate_to;
+pub use generator::Generator;
+pub use shells::Shell;
diff --git a/clap_complete/src/generators/shells/bash.rs b/clap_complete/src/shells/bash.rs
similarity index 98%
rename from clap_complete/src/generators/shells/bash.rs
rename to clap_complete/src/shells/bash.rs
index cbf9baf1..5db6693d 100644
--- a/clap_complete/src/generators/shells/bash.rs
+++ b/clap_complete/src/shells/bash.rs
@@ -1,12 +1,9 @@
-// Std
 use std::{fmt::Write as _, io::Write};
 
-// Internal
-use crate::utils;
-use crate::Generator;
-
 use clap::*;
 
+use crate::generator::{utils, Generator};
+
 /// Generate bash completion file
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Bash;
diff --git a/clap_complete/src/generators/shells/elvish.rs b/clap_complete/src/shells/elvish.rs
similarity index 98%
rename from clap_complete/src/generators/shells/elvish.rs
rename to clap_complete/src/shells/elvish.rs
index 24da18d7..17cd98ee 100644
--- a/clap_complete/src/generators/shells/elvish.rs
+++ b/clap_complete/src/shells/elvish.rs
@@ -1,12 +1,10 @@
-// Std
 use std::io::Write;
 
-// Internal
-use crate::utils;
-use crate::Generator;
-use crate::INTERNAL_ERROR_MSG;
 use clap::*;
 
+use crate::generator::{utils, Generator};
+use crate::INTERNAL_ERROR_MSG;
+
 /// Generate elvish completion file
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Elvish;
diff --git a/clap_complete/src/generators/shells/fish.rs b/clap_complete/src/shells/fish.rs
similarity index 99%
rename from clap_complete/src/generators/shells/fish.rs
rename to clap_complete/src/shells/fish.rs
index fdeaf12d..0cd165ce 100644
--- a/clap_complete/src/generators/shells/fish.rs
+++ b/clap_complete/src/shells/fish.rs
@@ -1,11 +1,9 @@
-// Std
 use std::io::Write;
 
-// Internal
-use crate::utils;
-use crate::Generator;
 use clap::*;
 
+use crate::generator::{utils, Generator};
+
 /// Generate fish completion file
 ///
 /// Note: The fish generator currently only supports named options (-o/--option), not positional arguments.
diff --git a/clap_complete/src/generators/shells/mod.rs b/clap_complete/src/shells/mod.rs
similarity index 72%
rename from clap_complete/src/generators/shells/mod.rs
rename to clap_complete/src/shells/mod.rs
index ef3f4e52..a08aa878 100644
--- a/clap_complete/src/generators/shells/mod.rs
+++ b/clap_complete/src/shells/mod.rs
@@ -1,11 +1,15 @@
+//! Shell-specific generators
+
 mod bash;
 mod elvish;
 mod fish;
 mod powershell;
+mod shell;
 mod zsh;
 
 pub use bash::Bash;
 pub use elvish::Elvish;
 pub use fish::Fish;
 pub use powershell::PowerShell;
+pub use shell::Shell;
 pub use zsh::Zsh;
diff --git a/clap_complete/src/generators/shells/powershell.rs b/clap_complete/src/shells/powershell.rs
similarity index 98%
rename from clap_complete/src/generators/shells/powershell.rs
rename to clap_complete/src/shells/powershell.rs
index 683d87af..4e3ad425 100644
--- a/clap_complete/src/generators/shells/powershell.rs
+++ b/clap_complete/src/shells/powershell.rs
@@ -1,12 +1,10 @@
-// Std
 use std::io::Write;
 
-// Internal
-use crate::utils;
-use crate::Generator;
-use crate::INTERNAL_ERROR_MSG;
 use clap::*;
 
+use crate::generator::{utils, Generator};
+use crate::INTERNAL_ERROR_MSG;
+
 /// Generate powershell completion file
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct PowerShell;
diff --git a/clap_complete/src/shell.rs b/clap_complete/src/shells/shell.rs
similarity index 75%
rename from clap_complete/src/shell.rs
rename to clap_complete/src/shells/shell.rs
index 042b33b8..09ad4965 100644
--- a/clap_complete/src/shell.rs
+++ b/clap_complete/src/shells/shell.rs
@@ -3,7 +3,8 @@ use std::str::FromStr;
 
 use clap::{ArgEnum, PossibleValue};
 
-use crate::{generators, Generator};
+use crate::shells;
+use crate::Generator;
 
 /// Shell with auto-generated completion script available.
 #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@@ -78,21 +79,21 @@ impl ArgEnum for Shell {
 impl Generator for Shell {
     fn file_name(&self, name: &str) -> String {
         match self {
-            Shell::Bash => generators::Bash.file_name(name),
-            Shell::Elvish => generators::Elvish.file_name(name),
-            Shell::Fish => generators::Fish.file_name(name),
-            Shell::PowerShell => generators::PowerShell.file_name(name),
-            Shell::Zsh => generators::Zsh.file_name(name),
+            Shell::Bash => shells::Bash.file_name(name),
+            Shell::Elvish => shells::Elvish.file_name(name),
+            Shell::Fish => shells::Fish.file_name(name),
+            Shell::PowerShell => shells::PowerShell.file_name(name),
+            Shell::Zsh => shells::Zsh.file_name(name),
         }
     }
 
     fn generate(&self, app: &clap::App, buf: &mut dyn std::io::Write) {
         match self {
-            Shell::Bash => generators::Bash.generate(app, buf),
-            Shell::Elvish => generators::Elvish.generate(app, buf),
-            Shell::Fish => generators::Fish.generate(app, buf),
-            Shell::PowerShell => generators::PowerShell.generate(app, buf),
-            Shell::Zsh => generators::Zsh.generate(app, buf),
+            Shell::Bash => shells::Bash.generate(app, buf),
+            Shell::Elvish => shells::Elvish.generate(app, buf),
+            Shell::Fish => shells::Fish.generate(app, buf),
+            Shell::PowerShell => shells::PowerShell.generate(app, buf),
+            Shell::Zsh => shells::Zsh.generate(app, buf),
         }
     }
 }
diff --git a/clap_complete/src/generators/shells/zsh.rs b/clap_complete/src/shells/zsh.rs
similarity index 99%
rename from clap_complete/src/generators/shells/zsh.rs
rename to clap_complete/src/shells/zsh.rs
index c2f9fb45..84ee0e8a 100644
--- a/clap_complete/src/generators/shells/zsh.rs
+++ b/clap_complete/src/shells/zsh.rs
@@ -1,12 +1,10 @@
-// Std
 use std::io::Write;
 
-// Internal
-use crate::utils;
-use crate::Generator;
-use crate::INTERNAL_ERROR_MSG;
 use clap::*;
 
+use crate::generator::{utils, Generator};
+use crate::INTERNAL_ERROR_MSG;
+
 /// Generate zsh completion file
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Zsh;
diff --git a/clap_complete_fig/src/fig.rs b/clap_complete_fig/src/fig.rs
index 9d345fc4..74403f09 100644
--- a/clap_complete_fig/src/fig.rs
+++ b/clap_complete_fig/src/fig.rs
@@ -160,7 +160,7 @@ fn gen_options(app: &App, indent: usize) -> String {
         buffer.push_str(&format!("{:indent$}}},\n", "", indent = indent + 2));
     }
 
-    for flag in utils::flags(app) {
+    for flag in generator::utils::flags(app) {
         buffer.push_str(&format!("{:indent$}{{\n", "", indent = indent + 2));
 
         let mut flags = vec![];
diff --git a/clap_generate/src/lib.rs b/clap_generate/src/lib.rs
index 5d13792b..84186589 100644
--- a/clap_generate/src/lib.rs
+++ b/clap_generate/src/lib.rs
@@ -10,12 +10,13 @@ pub use clap_complete::Shell;
 
 #[deprecated(since = "3.0.0", note = "Renamed to `clap_complete::generators`")]
 pub mod generators {
-    pub use clap_complete::generators::*;
+    pub use clap_complete::generator::*;
+    pub use clap_complete::shells::*;
 }
 
 #[deprecated(since = "3.0.0", note = "Renamed to `clap_complete::utils`")]
 pub mod utils {
-    pub use clap_complete::utils::*;
+    pub use clap_complete::generator::utils::*;
 }
 
 #[deprecated(since = "3.0.0", note = "Renamed to `clap_complete::generate_to`")]


Test patch:
diff --git a/clap_complete/tests/completions/mod.rs b/clap_complete/tests/completions/mod.rs
index 5ec5c9f2..7eaadd24 100644
--- a/clap_complete/tests/completions/mod.rs
+++ b/clap_complete/tests/completions/mod.rs
@@ -1,5 +1,5 @@
 use clap::{App, AppSettings, Arg, ValueHint};
-use clap_complete::{generate, generators::*};
+use clap_complete::{generate, shells::*, Generator};
 use std::fmt;
 
 mod bash;
diff --git a/clap_complete/tests/generate_completions.rs b/clap_complete/tests/generate_completions.rs
index 11b10be1..cfafe477 100644
--- a/clap_complete/tests/generate_completions.rs
+++ b/clap_complete/tests/generate_completions.rs
@@ -1,7 +1,9 @@
-use clap::{App, Arg};
-use clap_complete::{generate, generators::*};
 use std::io;
 
+use clap::{App, Arg};
+
+use clap_complete::{generate, shells::*};
+
 #[test]
 fn generate_completions() {
     let mut app = App::new("test_app")
diff --git a/clap_complete/tests/value_hints.rs b/clap_complete/tests/value_hints.rs
index 19213f81..e4f30a83 100644
--- a/clap_complete/tests/value_hints.rs
+++ b/clap_complete/tests/value_hints.rs
@@ -1,8 +1,9 @@
+mod completions;
+
 use clap::{App, AppSettings, Arg, ValueHint};
-use clap_complete::generators::*;
-use completions::common;
 
-mod completions;
+use clap_complete::shells::*;
+use completions::common;
 
 pub fn build_app_with_value_hints() -> App<'static> {
     App::new("my_app")
diff --git a/clap_complete_fig/tests/completions/mod.rs b/clap_complete_fig/tests/completions/mod.rs
index 885f281d..fc7f212f 100644
--- a/clap_complete_fig/tests/completions/mod.rs
+++ b/clap_complete_fig/tests/completions/mod.rs
@@ -1,5 +1,5 @@
 use clap::{App, AppSettings, Arg, ValueHint};
-use clap_complete::{generate, generators::*};
+use clap_complete::{generate, Generator};
 use std::fmt;
 
 mod fig;