mirror of
https://github.com/nushell/nushell.git
synced 2024-11-08 01:24:38 +01:00
Add param descriptions
This commit is contained in:
parent
6f1a5c8e02
commit
4249c5b3e0
@ -60,9 +60,9 @@ fn main() -> std::io::Result<()> {
|
||||
.required("block", SyntaxShape::Block, "body of the definition");
|
||||
working_set.add_decl(sig.into());
|
||||
|
||||
//let file = std::fs::read(&path)?;
|
||||
//let (output, err) = working_set.parse_file(&path, file);
|
||||
let (output, err) = working_set.parse_source(path.as_bytes());
|
||||
let file = std::fs::read(&path)?;
|
||||
let (output, err) = working_set.parse_file(&path, file);
|
||||
//let (output, err) = working_set.parse_source(path.as_bytes());
|
||||
println!("{:#?}", output);
|
||||
println!("error: {:?}", err);
|
||||
|
||||
|
@ -1008,16 +1008,10 @@ impl ParserWorkingSet {
|
||||
let syntax_shape = self.parse_shape_name(contents);
|
||||
//TODO check if we're replacing one already
|
||||
match last {
|
||||
Arg::Positional(PositionalArg { name, desc, shape }) => {
|
||||
Arg::Positional(PositionalArg { shape, .. }) => {
|
||||
*shape = syntax_shape;
|
||||
}
|
||||
Arg::Flag(Flag {
|
||||
long,
|
||||
short,
|
||||
arg,
|
||||
required,
|
||||
desc,
|
||||
}) => *arg = Some(syntax_shape),
|
||||
Arg::Flag(Flag { arg, .. }) => *arg = Some(syntax_shape),
|
||||
}
|
||||
}
|
||||
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 New Issue
Block a user