1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! `mandible --shell-init <shell>`: the snippet that turns
//! `--print-selection` into a key on the user's prompt.
//!
//! A TUI cannot type into the shell that launched it, so the handoff is the
//! one every picker uses: the shell runs mandible in a command
//! substitution, mandible draws on stderr and prints the composed command
//! on stdout, and the shell's own line editor puts that line where the
//! cursor is. bash does it through `READLINE_LINE`/`READLINE_POINT` in a
//! `bind -x` function; zsh through `BUFFER`/`CURSOR` in a zle widget.
//!
//! The snippets are files in this crate's own `shell/` directory, compiled
//! in with `include_str!` and printed by the binary rather than installed
//! to a path. They live *inside* the crate, not under the repo's
//! `packaging/`, because `cargo publish` verifies the build from the
//! packaged tarball and a tarball can only ever contain files under the
//! crate root โ 0.6.0's binary crate failed to publish with the snippets
//! one directory up, while every library crate went through. That is spec ยง15's completions rule applied to the same problem:
//! one generator, so no packaging channel can ship a snippet that
//! disagrees with the flags the installed binary actually has, and
//! `cargo install` users get it without any packaging at all.
use ValueEnum;
/// A shell `--shell-init` can emit an integration for.
///
/// Deliberately not `clap_complete::Shell`: that enum names every shell
/// clap can complete for, and this flag can only honestly offer the ones
/// with a snippet written and tested for them. Offering `fish` in the help
/// text and printing nothing for it would be worse than not offering it.