Skip to content

rust based bash completion - #272

Merged
ddiss merged 3 commits into
rapido-linux:masterfrom
ddiss:bash_completion_rs
May 29, 2026
Merged

rust based bash completion#272
ddiss merged 3 commits into
rapido-linux:masterfrom
ddiss:bash_completion_rs

Conversation

@ddiss

@ddiss ddiss commented May 29, 2026

Copy link
Copy Markdown
Collaborator
The following changes since commit 84545807b44dd7ee8e2e1371e0a2049752b1d2bf:

  libiscsi_test_tool: cut and autorun scripts (2026-05-22 21:56:15 +1000)

are available in the Git repository at:

  https://github.com/ddiss/rapido.git bash_completion_rs

for you to fetch changes up to 5df0448cbe3de587f81621b121270205616bdaa3:

  tools/bash_completion: complete via bash-completion.rs (2026-05-29 18:42:48 +1000)

----------------------------------------------------------------
David Disseldorp (3):
      bash-completion.rs: rust based rapido command completion
      bash-completions.rs: add simple test coverage
      tools/bash_completion: complete via bash-completion.rs

 src/bin/bash-completion.rs | 294 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/bash_completion      |  75 +++++-------------------------------
 2 files changed, 303 insertions(+), 66 deletions(-)
 create mode 100644 src/bin/bash-completion.rs

ddiss added 2 commits May 29, 2026 18:41
This is basically a rust conversion of the tools/bash_completion script.
It's usable via:
  complete -C $(realpath target/release/bash-completion) rapido

The main motivation for this conversion is distribution packaging: we
want to be able to set things like the rapido cut script path at build
time.
One other benefit is that we can add some unit test coverage. Completion
outputting functions carry an @out parameter, which tests can use to
capture completion output.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Capture the complete_rapido() output and compare it with what's
expected. The cut-script completion logic assumes that the test is
run from the parent rapido directory.

Signed-off-by: David Disseldorp <ddiss@suse.de>
@ddiss

ddiss commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Looks like there's an issue with the old ubuntu-latest CI rustc 1.85, resulting in:


error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
   --> src/bin/bash-completion.rs:280:30
    |
280 |             assert_eq!(&str::from_utf8(&out).unwrap(), exp);
    |                              ^^^^^^^^^ function or associated item not found in `str`
    |
help: you are looking for the module in `std`, not the primitive type
    |
280 |             assert_eq!(&std::str::from_utf8(&out).unwrap(), exp);
    |                         +++++

Remove the old bash __rapido() completion helper function and call the
new bash-completion.rs binary instead. Look under the script relative
../target/release path for it.

Signed-off-by: David Disseldorp <ddiss@suse.de>
@ddiss
ddiss force-pushed the bash_completion_rs branch from 5df0448 to e562733 Compare May 29, 2026 10:51
@ddiss

ddiss commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Looks like there's an issue with the old ubuntu-latest CI rustc 1.85, resulting in:
...

All it needed was a use std::str; for the test's from_utf8() call... guessing it's been moved from std into core since rustc 1.85(?)

@ddiss
ddiss merged commit e562733 into rapido-linux:master May 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant