Added -j flag to 'complete' for completing job names/pids
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::{
|
||||
getopt::Opt, libsh::term::{Style, Styled}, parse::lex::Span, prelude::*
|
||||
getopt::Opt,
|
||||
libsh::term::{Style, Styled},
|
||||
parse::lex::Span,
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub type ShResult<T> = Result<T, ShErr>;
|
||||
@@ -393,7 +396,7 @@ impl From<Errno> for ShErr {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ShErrKind {
|
||||
IoErr(io::ErrorKind),
|
||||
InvalidOpt,
|
||||
InvalidOpt,
|
||||
SyntaxErr,
|
||||
ParseErr,
|
||||
InternalErr,
|
||||
@@ -420,7 +423,7 @@ impl Display for ShErrKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let output = match self {
|
||||
Self::IoErr(e) => &format!("I/O Error: {e}"),
|
||||
Self::InvalidOpt => &format!("Invalid option"),
|
||||
Self::InvalidOpt => &format!("Invalid option"),
|
||||
Self::SyntaxErr => "Syntax Error",
|
||||
Self::ParseErr => "Parse Error",
|
||||
Self::InternalErr => "Internal Error",
|
||||
|
||||
@@ -17,7 +17,7 @@ pub trait CharDequeUtils {
|
||||
pub trait TkVecUtils<Tk> {
|
||||
fn get_span(&self) -> Option<Span>;
|
||||
fn debug_tokens(&self);
|
||||
fn split_at_separators(&self) -> Vec<Vec<Tk>>;
|
||||
fn split_at_separators(&self) -> Vec<Vec<Tk>>;
|
||||
}
|
||||
|
||||
pub trait RedirVecUtils<Redir> {
|
||||
@@ -86,29 +86,24 @@ impl TkVecUtils<Tk> for Vec<Tk> {
|
||||
fn debug_tokens(&self) {
|
||||
for token in self {}
|
||||
}
|
||||
fn split_at_separators(&self) -> Vec<Vec<Tk>> {
|
||||
let mut splits = vec![];
|
||||
let mut cur_split = vec![];
|
||||
for tk in self {
|
||||
match tk.class {
|
||||
TkRule::Pipe |
|
||||
TkRule::ErrPipe |
|
||||
TkRule::And |
|
||||
TkRule::Or |
|
||||
TkRule::Bg |
|
||||
TkRule::Sep => {
|
||||
splits.push(std::mem::take(&mut cur_split));
|
||||
}
|
||||
_ => cur_split.push(tk.clone()),
|
||||
}
|
||||
}
|
||||
fn split_at_separators(&self) -> Vec<Vec<Tk>> {
|
||||
let mut splits = vec![];
|
||||
let mut cur_split = vec![];
|
||||
for tk in self {
|
||||
match tk.class {
|
||||
TkRule::Pipe | TkRule::ErrPipe | TkRule::And | TkRule::Or | TkRule::Bg | TkRule::Sep => {
|
||||
splits.push(std::mem::take(&mut cur_split));
|
||||
}
|
||||
_ => cur_split.push(tk.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
if !cur_split.is_empty() {
|
||||
splits.push(cur_split);
|
||||
}
|
||||
if !cur_split.is_empty() {
|
||||
splits.push(cur_split);
|
||||
}
|
||||
|
||||
splits
|
||||
}
|
||||
splits
|
||||
}
|
||||
}
|
||||
|
||||
impl RedirVecUtils<Redir> for Vec<Redir> {
|
||||
|
||||
Reference in New Issue
Block a user