From b350adf8db96aa23320327517ffeaec9459e574e Mon Sep 17 00:00:00 2001 From: Cyncrovee Date: Fri, 5 Dec 2025 00:01:54 +0000 Subject: [PATCH] feat: allow optional arguments to be passed to rust-test This allows (optional) custom arguments to be passed the the rust-test function (press C-u before running the function). --- rust-cargo.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rust-cargo.el b/rust-cargo.el index d323b5d..a16618f 100644 --- a/rust-cargo.el +++ b/rust-cargo.el @@ -129,10 +129,18 @@ output buffer will be in comint mode, i.e. interactive." (interactive "P") (rust--compile comint "%s run --release" rust-cargo-bin)) -(defun rust-test () - "Test using `cargo test`" - (interactive) - (rust--compile nil "%s test %s" rust-cargo-bin rust-cargo-default-arguments)) +(defun rust-test (&optional arg) + "Test using `cargo test`. +If prefixed with `C-u`, pass additional arguments to the command (from a string read from the minibuffer)." + (interactive "P") + (let ((test-command + (if arg + (progn + (let ((custom-arg + (string-trim (read-string "Enter Arguments: ")))) + (concat "%s test " custom-arg " %s"))) + "%s test %s"))) + (rust--compile nil test-command rust-cargo-bin rust-cargo-default-arguments))) (defun rust-run-clippy () "Run `cargo clippy'."