SyntaxShape checking in Alias (#2377)

* initial, working for shallow internals

* add recurion on Block

* clean up/abstract, Invocations

* use Result

* inspection of Binary, tests

* improve code structure

* move arg shape inspection to Alias command

* add spanned errors, tests, cleanup for PR

* fix test, clippy
This commit is contained in:
Bailey Layzer
2020-08-19 20:18:55 -07:00
committed by GitHub
parent 6126209f57
commit ad395944ef
5 changed files with 268 additions and 8 deletions

View File

@ -1,5 +1,6 @@
use crate::hir::Block;
use crate::value::Value;
use crate::SyntaxShape;
use nu_errors::ShellError;
use nu_source::{b, DebugDocBuilder, PrettyDebug};
use serde::{Deserialize, Serialize};
@ -22,7 +23,7 @@ pub enum CommandAction {
/// Enter the help shell, which allows exploring the help system
EnterHelpShell(Value),
/// Enter the help shell, which allows exploring the help system
AddAlias(String, Vec<String>, Block),
AddAlias(String, Vec<(String, SyntaxShape)>, Block),
/// Go to the previous shell in the shell ring buffer
PreviousShell,
/// Go to the next shell in the shell ring buffer

View File

@ -2,7 +2,7 @@ use nu_source::{b, DebugDocBuilder, PrettyDebug};
use serde::{Deserialize, Serialize};
/// The syntactic shapes that values must match to be passed into a command. You can think of this as the type-checking that occurs when you call a function.
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
pub enum SyntaxShape {
/// Any syntactic form is allowed
Any,