mirror of
https://github.com/nushell/nushell
synced 2025-01-15 22:54:16 +00:00
Add param descriptions
This commit is contained in:
parent
6f1a5c8e02
commit
4249c5b3e0
2 changed files with 31 additions and 11 deletions
|
@ -60,9 +60,9 @@ fn main() -> std::io::Result<()> {
|
||||||
.required("block", SyntaxShape::Block, "body of the definition");
|
.required("block", SyntaxShape::Block, "body of the definition");
|
||||||
working_set.add_decl(sig.into());
|
working_set.add_decl(sig.into());
|
||||||
|
|
||||||
//let file = std::fs::read(&path)?;
|
let file = std::fs::read(&path)?;
|
||||||
//let (output, err) = working_set.parse_file(&path, file);
|
let (output, err) = working_set.parse_file(&path, file);
|
||||||
let (output, err) = working_set.parse_source(path.as_bytes());
|
//let (output, err) = working_set.parse_source(path.as_bytes());
|
||||||
println!("{:#?}", output);
|
println!("{:#?}", output);
|
||||||
println!("error: {:?}", err);
|
println!("error: {:?}", err);
|
||||||
|
|
||||||
|
|
|
@ -1008,16 +1008,10 @@ impl ParserWorkingSet {
|
||||||
let syntax_shape = self.parse_shape_name(contents);
|
let syntax_shape = self.parse_shape_name(contents);
|
||||||
//TODO check if we're replacing one already
|
//TODO check if we're replacing one already
|
||||||
match last {
|
match last {
|
||||||
Arg::Positional(PositionalArg { name, desc, shape }) => {
|
Arg::Positional(PositionalArg { shape, .. }) => {
|
||||||
*shape = syntax_shape;
|
*shape = syntax_shape;
|
||||||
}
|
}
|
||||||
Arg::Flag(Flag {
|
Arg::Flag(Flag { arg, .. }) => *arg = Some(syntax_shape),
|
||||||
long,
|
|
||||||
short,
|
|
||||||
arg,
|
|
||||||
required,
|
|
||||||
desc,
|
|
||||||
}) => *arg = Some(syntax_shape),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse_mode = ParseMode::ArgMode;
|
parse_mode = ParseMode::ArgMode;
|
||||||
|
@ -1025,6 +1019,32 @@ impl ParserWorkingSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Token {
|
||||||
|
contents: crate::TokenContents::Comment,
|
||||||
|
span,
|
||||||
|
} => {
|
||||||
|
let contents = &self.file_contents[span.start + 1..span.end];
|
||||||
|
|
||||||
|
let mut contents = String::from_utf8_lossy(contents).to_string();
|
||||||
|
contents = contents.trim().into();
|
||||||
|
|
||||||
|
if let Some(last) = args.last_mut() {
|
||||||
|
match last {
|
||||||
|
Arg::Flag(flag) => {
|
||||||
|
if !flag.desc.is_empty() {
|
||||||
|
flag.desc.push_str("\n");
|
||||||
|
}
|
||||||
|
flag.desc.push_str(&contents);
|
||||||
|
}
|
||||||
|
Arg::Positional(positional) => {
|
||||||
|
if !positional.desc.is_empty() {
|
||||||
|
positional.desc.push_str("\n");
|
||||||
|
}
|
||||||
|
positional.desc.push_str(&contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue