nu-cli: directory syntax shape + completions (#5299)

This commit is contained in:
Herlon Aguiar
2022-04-22 22:18:51 +02:00
committed by GitHub
parent 661283c4d2
commit 5ff2ae628b
15 changed files with 211 additions and 9 deletions

View File

@ -33,6 +33,7 @@ pub enum Expr {
ValueWithUnit(Box<Expression>, Spanned<Unit>),
DateTime(chrono::DateTime<FixedOffset>),
Filepath(String),
Directory(String),
GlobPattern(String),
String(String),
CellPath(CellPath),

View File

@ -162,6 +162,7 @@ impl Expression {
}
Expr::ImportPattern(_) => false,
Expr::Filepath(_) => false,
Expr::Directory(_) => false,
Expr::Float(_) => false,
Expr::FullCellPath(full_cell_path) => {
if full_cell_path.head.has_in_variable(working_set) {
@ -320,6 +321,7 @@ impl Expression {
}
}
Expr::Filepath(_) => {}
Expr::Directory(_) => {}
Expr::Float(_) => {}
Expr::FullCellPath(full_cell_path) => {
full_cell_path
@ -467,6 +469,7 @@ impl Expression {
}
}
Expr::Filepath(_) => {}
Expr::Directory(_) => {}
Expr::Float(_) => {}
Expr::FullCellPath(full_cell_path) => {
full_cell_path

View File

@ -34,6 +34,9 @@ pub enum SyntaxShape {
/// A filepath is allowed
Filepath,
/// A directory is allowed
Directory,
/// A glob pattern is allowed, eg `foo*`
GlobPattern,
@ -105,6 +108,7 @@ impl SyntaxShape {
SyntaxShape::Duration => Type::Duration,
SyntaxShape::Expression => Type::Any,
SyntaxShape::Filepath => Type::String,
SyntaxShape::Directory => Type::String,
SyntaxShape::Filesize => Type::Filesize,
SyntaxShape::FullCellPath => Type::Any,
SyntaxShape::GlobPattern => Type::String,
@ -145,6 +149,7 @@ impl Display for SyntaxShape {
SyntaxShape::Range => write!(f, "range"),
SyntaxShape::Int => write!(f, "int"),
SyntaxShape::Filepath => write!(f, "path"),
SyntaxShape::Directory => write!(f, "directory"),
SyntaxShape::GlobPattern => write!(f, "glob"),
SyntaxShape::ImportPattern => write!(f, "import"),
SyntaxShape::Block(_) => write!(f, "block"),