Skip to content

Commit bba1a44

Browse files
feat(cli): allow skipping rustfmt project reformatting when adding a plugin (#10457)
* feat(cli): allow skipping rustfmt project reformatting * Apply suggestions from code review * fixes, change file * fix change file --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
1 parent 92cac12 commit bba1a44

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.changes/cli-add-no-fmt.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": "patch:enhance"
3+
"@tauri-apps/cli": "patch:enhance"
4+
---
5+
6+
Added `--no-fmt` option to the `add` command to skip formatting the code after applying changes.

tooling/cli/src/add.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub struct Options {
8686
/// Git branch to use.
8787
#[clap(short, long)]
8888
pub branch: Option<String>,
89+
/// Don't format code with rustfmt
90+
#[clap(long)]
91+
pub no_fmt: bool,
8992
}
9093

9194
pub fn command(options: Options) -> Result<()> {
@@ -185,12 +188,15 @@ pub fn command(options: Options) -> Result<()> {
185188
log::info!("Adding plugin to {}", file.display());
186189
std::fs::write(file, out.as_bytes())?;
187190

188-
// run cargo fmt
189-
log::info!("Running `cargo fmt`...");
190-
let _ = Command::new("cargo")
191-
.arg("fmt")
192-
.current_dir(&tauri_dir)
193-
.status();
191+
if !options.no_fmt {
192+
// reformat code with rustfmt
193+
log::info!("Running `cargo fmt`...");
194+
let _ = Command::new("cargo")
195+
.arg("fmt")
196+
.current_dir(&tauri_dir)
197+
.status();
198+
}
199+
194200
return Ok(());
195201
}
196202
}

tooling/cli/src/migrate/migrations/v1/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub fn run() -> Result<()> {
2828
branch: None,
2929
tag: None,
3030
rev: None,
31+
no_fmt: false,
3132
})
3233
.with_context(|| format!("Could not migrate plugin '{plugin}'"))?;
3334
}

0 commit comments

Comments
 (0)