clap_dyn_complete

Function emit_completion_stub

Source
pub fn emit_completion_stub(
    shell: Shell,
    bin_name: &str,
    completion_subcommand: &str,
    buf: &mut dyn Write,
) -> Result<()>
Expand description

Emits a minimal “shell adapter” script, tailored to the particular bin.

completion_subcommand should be a string corresponding to the name of the subcommand that invokes Complete.

  • e.g: a bin that has my-bin complete ... should pass "complete"
  • e.g: a bin that has my-bin dev complete ... should pass "dev complete"

NOTE: Feel free to ignore / modify these stubs to suit your particular use-case! e.g: These stubs will not work in cases where the binary is invoked as a subcommand (e.g: cargo xtask). In those cases, you may need to write additional shell-specific logic!