command arguments are now underlined if they match an existing path -m ran rustfmt on the entire codebase
This commit is contained in:
@@ -9,14 +9,14 @@ pub type OptSet = Arc<[Opt]>;
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Opt {
|
||||
Long(String),
|
||||
LongWithArg(String,String),
|
||||
LongWithArg(String, String),
|
||||
Short(char),
|
||||
ShortWithArg(char,String),
|
||||
ShortWithArg(char, String),
|
||||
}
|
||||
|
||||
pub struct OptSpec {
|
||||
pub opt: Opt,
|
||||
pub takes_arg: bool,
|
||||
pub opt: Opt,
|
||||
pub takes_arg: bool,
|
||||
}
|
||||
|
||||
impl Opt {
|
||||
@@ -41,8 +41,8 @@ impl Display for Opt {
|
||||
match self {
|
||||
Self::Long(opt) => write!(f, "--{}", opt),
|
||||
Self::Short(opt) => write!(f, "-{}", opt),
|
||||
Self::LongWithArg(opt, arg) => write!(f, "--{} {}", opt, arg),
|
||||
Self::ShortWithArg(opt, arg) => write!(f, "-{} {}", opt, arg)
|
||||
Self::LongWithArg(opt, arg) => write!(f, "--{} {}", opt, arg),
|
||||
Self::ShortWithArg(opt, arg) => write!(f, "-{} {}", opt, arg),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,32 +82,33 @@ pub fn get_opts_from_tokens(tokens: Vec<Tk>, opt_specs: &[OptSpec]) -> (Vec<Tk>,
|
||||
if parsed_opts.is_empty() {
|
||||
non_opts.push(token)
|
||||
} else {
|
||||
for opt in parsed_opts {
|
||||
let mut pushed = false;
|
||||
for opt_spec in opt_specs {
|
||||
if opt_spec.opt == opt {
|
||||
if opt_spec.takes_arg {
|
||||
let arg = tokens_iter.next()
|
||||
.map(|t| t.to_string())
|
||||
.unwrap_or_default();
|
||||
for opt in parsed_opts {
|
||||
let mut pushed = false;
|
||||
for opt_spec in opt_specs {
|
||||
if opt_spec.opt == opt {
|
||||
if opt_spec.takes_arg {
|
||||
let arg = tokens_iter
|
||||
.next()
|
||||
.map(|t| t.to_string())
|
||||
.unwrap_or_default();
|
||||
|
||||
let opt = match opt {
|
||||
Opt::Long(ref opt) => Opt::LongWithArg(opt.to_string(), arg),
|
||||
Opt::Short(opt) => Opt::ShortWithArg(opt, arg),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
opts.push(opt);
|
||||
pushed = true;
|
||||
} else {
|
||||
opts.push(opt.clone());
|
||||
pushed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !pushed {
|
||||
non_opts.push(token.clone());
|
||||
}
|
||||
}
|
||||
let opt = match opt {
|
||||
Opt::Long(ref opt) => Opt::LongWithArg(opt.to_string(), arg),
|
||||
Opt::Short(opt) => Opt::ShortWithArg(opt, arg),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
opts.push(opt);
|
||||
pushed = true;
|
||||
} else {
|
||||
opts.push(opt.clone());
|
||||
pushed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !pushed {
|
||||
non_opts.push(token.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(non_opts, opts)
|
||||
|
||||
Reference in New Issue
Block a user