cli_xtask/subcommand/
pre_release.rs

1use crate::{config::Config, Result, Run, SubcommandRun};
2
3/// Arguments definition of the `pre-release` subcommand.
4#[cfg_attr(doc, doc = include_str!("../../doc/cargo-xtask-pre-release.md"))]
5#[derive(Debug, Clone, Default, clap::Args)]
6#[non_exhaustive]
7pub struct PreRelease {}
8
9impl Run for PreRelease {
10    fn run(&self, config: &Config) -> Result<()> {
11        self.run(config)
12    }
13
14    fn to_subcommands(&self) -> Option<SubcommandRun> {
15        Some(self.to_subcommands())
16    }
17}
18
19impl PreRelease {
20    /// Returns a list of all subcommands to run.
21    pub fn subcommands(&self) -> Vec<Box<dyn Run>> {
22        let Self {} = self;
23        vec![
24            #[cfg(feature = "subcommand-lint")]
25            Box::new(super::Lint {
26                feature_args: crate::args::FeatureArgs::EXHAUSTIVE,
27            }),
28            #[cfg(feature = "subcommand-test")]
29            Box::new(super::Test {
30                env_args: Default::default(),
31                feature_args: crate::args::FeatureArgs::EXHAUSTIVE,
32                extra_options: vec![],
33            }),
34        ]
35    }
36
37    /// Returns the subcommands that this command will run.
38    pub fn to_subcommands(&self) -> SubcommandRun {
39        SubcommandRun::new(self.subcommands())
40    }
41
42    /// Runs the `pre-release` subcommand.
43    #[tracing::instrument(name = "pre-release", skip_all, err)]
44    pub fn run(&self, config: &Config) -> Result<()> {
45        self.to_subcommands().run(config)
46    }
47}