Skip to content

Conversation

DaAlbrecht
Copy link
Collaborator

Objective

Pass --version and --fix to bevy_lint. Additionally, support passing arbitrary arguments to bevy_lint.

Testing

Printing the version of bevy_lint

❯ bevy lint --version
bevy_lint v0.5.0-dev

Passing arbitrary arguments to bevy_lint

❯ bevy lint --  --help
A custom linter for the Bevy game engine

Usage: bevy_lint [OPTIONS]

Options:
  --fix          Automatically apply lint suggestions if possible
  -h, --help     Prints the help text and exits
  -V, --version  Prints the version info and exits

In addition to the options listed above, bevy_lint supports all of cargo check's
options, which you can view with cargo check --help. If you pass --fix,
bevy_lint will support all of cargo fix's options instead.

bevy_lint --fix

This wonderful bit of code:

use bevy::prelude::*;

fn main() {
    println!("Hello, world!");
}

pub fn test_commands(mut commands_owned: Commands) {
    commands_owned.spawn(());
}

produces the following output:

❯ bevy lint --fix
error: the working directory of this package has uncommitted changes, and `cargo fix` can potentially perform destructive changes; if you'd like to suppress this error pass `--allow-dirty`, or commit the changes to these files:

  * .gitignore (dirty)
  * Cargo.lock (dirty)
  * Cargo.toml (dirty)
  * src/ (dirty)


Check failed: exit status: 101.
error: command `bevy_lint --fix --profile dev` exited with status code exit status: 101

Now with ``--allow-dirty` (we forward this flag, the cli does not know about it)

❯ bevy lint --fix -- --allow-dirty
    Checking autofix v0.1.0 (/tmp/autofix)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
❯ cat -p src/main.rs
use bevy::prelude::*;

fn main() {
    println!("Hello, world!");
}

pub fn test_commands(mut commands_owned: Commands) {
    commands_owned.spawn_empty();
}

Complexer command

So to run bevy_lint fix for the web in verbose mode and apply fixes to our uncommitted git directory, we would have to do this:

❯ bevy lint --fix -v web -- --allow-dirty

@DaAlbrecht DaAlbrecht added A-CLI Related to the main CLI and not a more specific subcommand A-Linter Related to the linter and custom lints D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged labels Aug 27, 2025
@DaAlbrecht DaAlbrecht added this to the `bevy_cli` v0.1.0-alpha.2 milestone Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Related to the main CLI and not a more specific subcommand A-Linter Related to the linter and custom lints D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant