mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 11:54:02 +01:00
Completions: add support for doas as for sudo (#10256)
# Description Fixes #2047 but for the `doas` command the same way as in #8094 # User-Facing Changes No breaking changes. If people not using `doas`, no difference at all. # Tests I have not added any tests since its using same logic as for "sudo". I guess if something would go wrong in this part, sudo tests will cover it? # Additional context As a nushell user I could not find a way to implement custom completion for a "sudo like command". Since I can see `sudo` being hardcoded in sources, this is what I propose. ~~Also I have almost zero knowledge of rust and this is definitely not the clean way yet~~ --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
d1dc610769
commit
80220b722b
1
.github/.typos.toml
vendored
1
.github/.typos.toml
vendored
@ -11,3 +11,4 @@ Plasticos = "Plasticos"
|
|||||||
IIF = "IIF"
|
IIF = "IIF"
|
||||||
numer = "numer"
|
numer = "numer"
|
||||||
ratatui = "ratatui"
|
ratatui = "ratatui"
|
||||||
|
doas = "doas"
|
||||||
|
@ -234,7 +234,7 @@ pub fn is_passthrough_command(working_set_file_contents: &[(Vec<u8>, usize, usiz
|
|||||||
let cur_pos = find_non_whitespace_index(contents, last_pipe_pos);
|
let cur_pos = find_non_whitespace_index(contents, last_pipe_pos);
|
||||||
|
|
||||||
let result = match contents.get(cur_pos..) {
|
let result = match contents.get(cur_pos..) {
|
||||||
Some(contents) => contents.starts_with(b"sudo "),
|
Some(contents) => contents.starts_with(b"sudo ") || contents.starts_with(b"doas "),
|
||||||
None => false,
|
None => false,
|
||||||
};
|
};
|
||||||
if result {
|
if result {
|
||||||
|
@ -136,7 +136,9 @@ impl NuCompleter {
|
|||||||
for (flat_idx, flat) in flattened.iter().enumerate() {
|
for (flat_idx, flat) in flattened.iter().enumerate() {
|
||||||
let is_passthrough_command = spans
|
let is_passthrough_command = spans
|
||||||
.first()
|
.first()
|
||||||
.filter(|content| content.as_str() == "sudo")
|
.filter(|content| {
|
||||||
|
content.as_str() == "sudo" || content.as_str() == "doas"
|
||||||
|
})
|
||||||
.is_some();
|
.is_some();
|
||||||
// Read the current spam to string
|
// Read the current spam to string
|
||||||
let current_span = working_set.get_span_contents(flat.0).to_vec();
|
let current_span = working_set.get_span_contents(flat.0).to_vec();
|
||||||
|
Loading…
Reference in New Issue
Block a user