completers 0.0.1

A tiny Rust-native shell completion solution.
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented1 out of 6 items with examples
  • Size
  • Source code size: 20.36 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.54 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • PRO-2684/completers
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PRO-2684

completers

GitHub License GitHub Workflow Status GitHub Release GitHub Downloads (all assets, all releases) Crates.io Version Crates.io Total Downloads docs.rs

[!WARNING] This crate is still a prototype, and is subject to BREAKING changes without notice.

A tiny Rust-native shell completion solution.

💡 Examples

See examples for a few examples of how to use this crate.

📖 Usage

Rust Part

First, define a completion handler function that takes a [Completion] struct as an argument and returns a vector of completion candidates:

use completers::Completion;

fn handler(_completion: Completion) -> Vec<String> {
    vec![]
}

Then, call [handle_completion] BEFORE any other command that writes to stdout in your main function:

use completers::{Completion, handle_completion};

fn main() {
    handle_completion(handler);
    // Other logic
}
#
# fn handler(_completion: Completion) -> Vec<String> {
#     vec![]
# }

Shell Part

Generate and evaluate the shell code via:

source <(COMPLETE=bash my_binary)

You should be able to complete your commands now. To enable completion across all your terminal sessions, you can add the above code to your completions directory, like:

mkdir -p ~/.local/share/bash-completion/completions # Create the directory if it doesn't exist
echo 'source <(COMPLETE=bash my_binary)' > ~/.local/share/bash-completion/completions/my_binary

The completers Binary

Currently, the completers binary does nothing.

⚙️ Mechanism

See MECHANISM.md for a detailed explanation of how this works, in case you're curious.

🎉 Credits

✅ TODO

  • Escape special characters in generated shell code & completion candidates
  • Completion delegation
    • Need to consider how to design the API
    • Prototypes available in prototype
  • Extensibility (API?)