Add path completions

This commit is contained in:
JT
2021-10-05 08:21:31 +13:00
parent 2b5cc63118
commit a88058006a
12 changed files with 182 additions and 11 deletions

View File

@ -15,7 +15,7 @@ impl Command for Cd {
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("cd").optional("path", SyntaxShape::FilePath, "the path to change to")
Signature::build("cd").optional("path", SyntaxShape::Filepath, "the path to change to")
}
fn run(

View File

@ -31,7 +31,14 @@ impl Command for Ls {
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
let pattern = if let Some(expr) = call.positional.get(0) {
let result = eval_expression(context, expr)?;
result.as_string()?
let mut result = result.as_string()?;
let path = std::path::Path::new(&result);
if path.is_dir() {
result.push('*');
}
result
} else {
"*".into()
};