Restructure ci modules (#13101)

# Objective

- Currently all `ci` commands are in the `subcommands` module. This is
problematic when you want to implement actually subcommands (such as
`cargo r -p ci -- doc check`).
- All command modules include the `_command` suffix, which is redundant.

## Solution

- Move `commands` modules into root crate folder.
- Merge contents of `commands/mod.rs` into `main.rs`.
- Move `commands::subcommands` module into `commands` module.
- Remove the `_command` suffix from all `commands::subcommands` modules.
This commit is contained in:
BD103 2024-04-25 14:52:11 -04:00 committed by GitHub
parent 5b899b48f5
commit 9c17fc2d8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 78 additions and 79 deletions

View file

@ -1,5 +1,5 @@
use crate::commands::prepare::{Flag, Prepare, PreparedCommand};
use crate::commands::subcommands;
use crate::commands;
use crate::prepare::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
/// The CI command line tool for Bevy.
@ -62,17 +62,17 @@ impl CI {
None => {
// Note that we are running the subcommands directly rather than using any aliases
let mut cmds = vec![];
cmds.append(&mut subcommands::FormatCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::ClippyCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::TestCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::TestCheckCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::DocCheckCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::DocTestCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::CompileCheckCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::CfgCheckCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::CompileFailCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::BenchCheckCommand::default().prepare(sh, flags));
cmds.append(&mut subcommands::ExampleCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::FormatCommand::default().prepare(sh, flags));
cmds.append(&mut commands::ClippyCommand::default().prepare(sh, flags));
cmds.append(&mut commands::TestCommand::default().prepare(sh, flags));
cmds.append(&mut commands::TestCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::DocCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::DocTestCommand::default().prepare(sh, flags));
cmds.append(&mut commands::CompileCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::CfgCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::CompileFailCommand::default().prepare(sh, flags));
cmds.append(&mut commands::BenchCheckCommand::default().prepare(sh, flags));
cmds.append(&mut commands::ExampleCheckCommand::default().prepare(sh, flags));
cmds
}
}
@ -84,21 +84,21 @@ impl CI {
#[argh(subcommand)]
enum Commands {
// Aliases (subcommands that run other subcommands)
Lints(subcommands::LintsCommand),
Doc(subcommands::DocCommand),
Compile(subcommands::CompileCommand),
Lints(commands::LintsCommand),
Doc(commands::DocCommand),
Compile(commands::CompileCommand),
// Actual subcommands
Format(subcommands::FormatCommand),
Clippy(subcommands::ClippyCommand),
Test(subcommands::TestCommand),
TestCheck(subcommands::TestCheckCommand),
DocCheck(subcommands::DocCheckCommand),
DocTest(subcommands::DocTestCommand),
CompileCheck(subcommands::CompileCheckCommand),
CfgCheck(subcommands::CfgCheckCommand),
CompileFail(subcommands::CompileFailCommand),
BenchCheck(subcommands::BenchCheckCommand),
ExampleCheck(subcommands::ExampleCheckCommand),
Format(commands::FormatCommand),
Clippy(commands::ClippyCommand),
Test(commands::TestCommand),
TestCheck(commands::TestCheckCommand),
DocCheck(commands::DocCheckCommand),
DocTest(commands::DocTestCommand),
CompileCheck(commands::CompileCheckCommand),
CfgCheck(commands::CfgCheckCommand),
CompileFail(commands::CompileFailCommand),
BenchCheck(commands::BenchCheckCommand),
ExampleCheck(commands::ExampleCheckCommand),
}
impl Prepare for Commands {

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,8 +1,8 @@
use crate::commands::subcommands::{
use crate::commands::{
BenchCheckCommand, CompileCheckCommand, CompileFailCommand, ExampleCheckCommand,
TestCheckCommand,
};
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
/// Alias for running the `compile-fail`, `bench-check`, `example-check`, `compile-check`, and `test-check` subcommands.

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,5 +1,5 @@
use crate::commands::subcommands::{DocCheckCommand, DocTestCommand};
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::commands::{DocCheckCommand, DocTestCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
/// Alias for running the `doc-test` and `doc-check` subcommands.

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,5 +1,5 @@
use crate::commands::subcommands::{ClippyCommand, FormatCommand};
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::commands::{ClippyCommand, FormatCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
/// Alias for running the `format` and `clippy` subcommands.

View file

@ -1,6 +1,29 @@
pub(crate) use ci::*;
use prepare::*;
pub(crate) use bench_check::*;
pub(crate) use cfg_check::*;
pub(crate) use clippy::*;
pub(crate) use compile::*;
pub(crate) use compile_check::*;
pub(crate) use compile_fail::*;
pub(crate) use doc::*;
pub(crate) use doc_check::*;
pub(crate) use doc_test::*;
pub(crate) use example_check::*;
pub(crate) use format::*;
pub(crate) use lints::*;
pub(crate) use test::*;
pub(crate) use test_check::*;
mod ci;
mod prepare;
mod subcommands;
mod bench_check;
mod cfg_check;
mod clippy;
mod compile;
mod compile_check;
mod compile_fail;
mod doc;
mod doc_check;
mod doc_test;
mod example_check;
mod format;
mod lints;
mod test;
mod test_check;

View file

@ -1,29 +0,0 @@
pub(crate) use bench_check_command::*;
pub(crate) use cfg_check_command::*;
pub(crate) use clippy_command::*;
pub(crate) use compile_check_command::*;
pub(crate) use compile_command::*;
pub(crate) use compile_fail_command::*;
pub(crate) use doc_check_command::*;
pub(crate) use doc_command::*;
pub(crate) use doc_test_command::*;
pub(crate) use example_check_command::*;
pub(crate) use format_command::*;
pub(crate) use lints_command::*;
pub(crate) use test_check_command::*;
pub(crate) use test_command::*;
mod bench_check_command;
mod cfg_check_command;
mod clippy_command;
mod compile_check_command;
mod compile_command;
mod compile_fail_command;
mod doc_check_command;
mod doc_command;
mod doc_test_command;
mod example_check_command;
mod format_command;
mod lints_command;
mod test_check_command;
mod test_command;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,4 +1,4 @@
use crate::commands::{Flag, Prepare, PreparedCommand};
use crate::{Flag, Prepare, PreparedCommand};
use argh::FromArgs;
use xshell::cmd;

View file

@ -1,7 +1,12 @@
//! CI script used for Bevy.
mod ci;
mod commands;
mod prepare;
pub(crate) use self::ci::*;
pub(crate) use self::prepare::*;
fn main() {
argh::from_env::<commands::CI>().run();
argh::from_env::<CI>().run();
}