mirror of
https://github.com/nushell/nushell.git
synced 2024-11-15 21:14:40 +01:00
commit
1ea124a65b
@ -82,7 +82,9 @@ impl Completer for NuCompleter {
|
|||||||
Ok(Value::List { vals, .. }) => vals
|
Ok(Value::List { vals, .. }) => vals
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(move |x| {
|
.map(move |x| {
|
||||||
let s = x.as_string().expect("FIXME");
|
let s = x.as_string().expect(
|
||||||
|
"FIXME: better error handling for custom completions",
|
||||||
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
reedline::Span {
|
reedline::Span {
|
||||||
|
@ -93,7 +93,7 @@ fn into_binary(
|
|||||||
|
|
||||||
input.map(head, move |v| {
|
input.map(head, move |v| {
|
||||||
action(v, head)
|
action(v, head)
|
||||||
// FIXME: Add back in column path support
|
// FIXME: Add back in cell_path support
|
||||||
// if column_paths.is_empty() {
|
// if column_paths.is_empty() {
|
||||||
// action(v, head)
|
// action(v, head)
|
||||||
// } else {
|
// } else {
|
||||||
|
@ -22,7 +22,7 @@ pub fn create_default_context() -> Rc<RefCell<EngineState>> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: sort items categorically
|
// TODO: sort default context items categorically
|
||||||
bind_command!(
|
bind_command!(
|
||||||
Alias,
|
Alias,
|
||||||
Benchmark,
|
Benchmark,
|
||||||
|
@ -37,13 +37,13 @@ impl Command for Git {
|
|||||||
Ok(Value::string(&String::from_utf8_lossy(&result), call.head))
|
Ok(Value::string(&String::from_utf8_lossy(&result), call.head))
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
// FIXME
|
// FIXME: Move this to an external signature and add better error handling
|
||||||
Ok(Value::nothing())
|
Ok(Value::nothing())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
// FIXME
|
// FIXME: Move this to an external signature and add better error handling
|
||||||
Ok(Value::nothing())
|
Ok(Value::nothing())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ impl Command for GitCheckout {
|
|||||||
Ok(Value::string(&String::from_utf8_lossy(&result), call.head))
|
Ok(Value::string(&String::from_utf8_lossy(&result), call.head))
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
// FIXME
|
// FIXME: Move this to an external signature and add better error handling
|
||||||
Ok(Value::nothing())
|
Ok(Value::nothing())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
// FIXME
|
// FIXME: Move this to an external signature and add better error handling
|
||||||
Ok(Value::nothing())
|
Ok(Value::nothing())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ impl Command for Mv {
|
|||||||
call: &Call,
|
call: &Call,
|
||||||
_input: Value,
|
_input: Value,
|
||||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||||
// TODO: handle invalid directory or insufficient permissions
|
// TODO: handle invalid directory or insufficient permissions when moving
|
||||||
let source: String = call.req(context, 0)?;
|
let source: String = call.req(context, 0)?;
|
||||||
let destination: String = call.req(context, 1)?;
|
let destination: String = call.req(context, 1)?;
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ impl Command for Each {
|
|||||||
Value::Record {
|
Value::Record {
|
||||||
mut cols, mut vals, ..
|
mut cols, mut vals, ..
|
||||||
} => {
|
} => {
|
||||||
// TODO check that the lengths match
|
// TODO check that the lengths match when traversing record
|
||||||
output_cols.append(&mut cols);
|
output_cols.append(&mut cols);
|
||||||
output_vals.append(&mut vals);
|
output_vals.append(&mut vals);
|
||||||
}
|
}
|
||||||
@ -235,7 +235,6 @@ impl Command for Each {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
x => {
|
x => {
|
||||||
//TODO: we need to watch to make sure this is okay
|
|
||||||
let engine_state = context.engine_state.borrow();
|
let engine_state = context.engine_state.borrow();
|
||||||
let block = engine_state.get_block(block_id);
|
let block = engine_state.get_block(block_id);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const COMMANDS_DOCS_DIR: &str = "docs/commands";
|
|||||||
|
|
||||||
pub struct DocumentationConfig {
|
pub struct DocumentationConfig {
|
||||||
no_subcommands: bool,
|
no_subcommands: bool,
|
||||||
//FIXME:
|
//FIXME: add back in color support
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
no_color: bool,
|
no_color: bool,
|
||||||
brief: bool,
|
brief: bool,
|
||||||
|
@ -100,19 +100,6 @@ impl FromValue for Spanned<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME
|
|
||||||
/*
|
|
||||||
impl FromValue for ColumnPath {
|
|
||||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
|
||||||
match v {
|
|
||||||
Value:: => Ok(c.clone()),
|
|
||||||
v => Err(ShellError::type_error("column path", v.spanned_type_name())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
impl FromValue for CellPath {
|
impl FromValue for CellPath {
|
||||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||||
let span = v.span()?;
|
let span = v.span()?;
|
||||||
|
@ -89,8 +89,7 @@ pub enum ParseError {
|
|||||||
#[diagnostic(
|
#[diagnostic(
|
||||||
code(nu::parser::unknown_command),
|
code(nu::parser::unknown_command),
|
||||||
url(docsrs),
|
url(docsrs),
|
||||||
// TODO: actual suggestions
|
// TODO: actual suggestions like "Did you mean `foo`?"
|
||||||
// help("Did you mean `foo`?")
|
|
||||||
)]
|
)]
|
||||||
UnknownCommand(#[label = "unknown command"] Span),
|
UnknownCommand(#[label = "unknown command"] Span),
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ pub fn parse_def(
|
|||||||
*declaration = signature.into_block_command(block_id);
|
*declaration = signature.into_block_command(block_id);
|
||||||
} else {
|
} else {
|
||||||
error = error.or_else(|| {
|
error = error.or_else(|| {
|
||||||
// TODO: Add InternalError variant
|
// FIXME: add a variant to ParseError that represents internal errors
|
||||||
Some(ParseError::UnknownState(
|
Some(ParseError::UnknownState(
|
||||||
"Internal error: Predeclaration failed to add declaration"
|
"Internal error: Predeclaration failed to add declaration"
|
||||||
.into(),
|
.into(),
|
||||||
@ -307,7 +307,7 @@ pub fn parse_export(
|
|||||||
(
|
(
|
||||||
garbage_statement(spans),
|
garbage_statement(spans),
|
||||||
Some(ParseError::UnknownState(
|
Some(ParseError::UnknownState(
|
||||||
// TODO: fill in more as they come
|
// TODO: fill in more export types as they come
|
||||||
"Expected structure: export def [] {}".into(),
|
"Expected structure: export def [] {}".into(),
|
||||||
span(spans),
|
span(spans),
|
||||||
)),
|
)),
|
||||||
@ -400,7 +400,7 @@ pub fn parse_module(
|
|||||||
let name = working_set.get_span_contents(pipeline.commands[0].parts[0]);
|
let name = working_set.get_span_contents(pipeline.commands[0].parts[0]);
|
||||||
|
|
||||||
let (stmt, err) = match name {
|
let (stmt, err) = match name {
|
||||||
// TODO: Here we can add other stuff that's alowed for modules
|
// TODO: Here we can add other stuff that's allowed for modules
|
||||||
b"def" => {
|
b"def" => {
|
||||||
let (stmt, err) = parse_def(working_set, &pipeline.commands[0].parts);
|
let (stmt, err) = parse_def(working_set, &pipeline.commands[0].parts);
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ pub fn parse_module(
|
|||||||
_ => (
|
_ => (
|
||||||
garbage_statement(&pipeline.commands[0].parts),
|
garbage_statement(&pipeline.commands[0].parts),
|
||||||
Some(ParseError::Expected(
|
Some(ParseError::Expected(
|
||||||
// TODO: Fill in more as they com
|
// TODO: Fill in more keywords as they come
|
||||||
"def or export keyword".into(),
|
"def or export keyword".into(),
|
||||||
pipeline.commands[0].parts[0],
|
pipeline.commands[0].parts[0],
|
||||||
)),
|
)),
|
||||||
|
@ -149,7 +149,7 @@ fn parse_long_flag(
|
|||||||
let arg_contents = working_set.get_span_contents(arg_span);
|
let arg_contents = working_set.get_span_contents(arg_span);
|
||||||
|
|
||||||
if arg_contents.starts_with(b"--") {
|
if arg_contents.starts_with(b"--") {
|
||||||
// FIXME: only use the first you find
|
// FIXME: only use the first flag you find?
|
||||||
let split: Vec<_> = arg_contents.split(|x| *x == b'=').collect();
|
let split: Vec<_> = arg_contents.split(|x| *x == b'=').collect();
|
||||||
let long_name = String::from_utf8(split[0].into());
|
let long_name = String::from_utf8(split[0].into());
|
||||||
if let Ok(long_name) = long_name {
|
if let Ok(long_name) = long_name {
|
||||||
@ -580,7 +580,7 @@ pub fn parse_internal_call(
|
|||||||
working_set.exit_scope();
|
working_set.exit_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: type unknown
|
// FIXME: output type unknown
|
||||||
(Box::new(call), span(spans), error)
|
(Box::new(call), span(spans), error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,7 +728,7 @@ pub fn parse_call(
|
|||||||
Expression {
|
Expression {
|
||||||
expr: Expr::Call(call),
|
expr: Expr::Call(call),
|
||||||
span: span(spans),
|
span: span(spans),
|
||||||
ty: Type::Unknown, // FIXME
|
ty: Type::Unknown, // FIXME: calls should have known output types
|
||||||
custom_completion: None,
|
custom_completion: None,
|
||||||
},
|
},
|
||||||
err,
|
err,
|
||||||
@ -922,7 +922,7 @@ pub fn parse_range(
|
|||||||
|
|
||||||
// Now, based on the operator positions, figure out where the bounds & next are located and
|
// Now, based on the operator positions, figure out where the bounds & next are located and
|
||||||
// parse them
|
// parse them
|
||||||
// TODO: Actually parse the next number
|
// TODO: Actually parse the next number in the range
|
||||||
let from = if token.starts_with("..") {
|
let from = if token.starts_with("..") {
|
||||||
// token starts with either next operator, or range operator -- we don't care which one
|
// token starts with either next operator, or range operator -- we don't care which one
|
||||||
None
|
None
|
||||||
@ -1260,7 +1260,6 @@ pub fn parse_full_cell_path(
|
|||||||
implicit_head: Option<VarId>,
|
implicit_head: Option<VarId>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> (Expression, Option<ParseError>) {
|
) -> (Expression, Option<ParseError>) {
|
||||||
// FIXME: assume for now a paren expr, but needs more
|
|
||||||
let full_cell_span = span;
|
let full_cell_span = span;
|
||||||
let source = working_set.get_span_contents(span);
|
let source = working_set.get_span_contents(span);
|
||||||
let mut error = None;
|
let mut error = None;
|
||||||
@ -1642,7 +1641,7 @@ pub fn parse_string(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Handle error case
|
//TODO: Handle error case for unknown shapes
|
||||||
pub fn parse_shape_name(
|
pub fn parse_shape_name(
|
||||||
_working_set: &StateWorkingSet,
|
_working_set: &StateWorkingSet,
|
||||||
bytes: &[u8],
|
bytes: &[u8],
|
||||||
@ -1657,7 +1656,7 @@ pub fn parse_shape_name(
|
|||||||
b"int" => SyntaxShape::Int,
|
b"int" => SyntaxShape::Int,
|
||||||
b"path" => SyntaxShape::Filepath,
|
b"path" => SyntaxShape::Filepath,
|
||||||
b"glob" => SyntaxShape::GlobPattern,
|
b"glob" => SyntaxShape::GlobPattern,
|
||||||
b"block" => SyntaxShape::Block(None), //FIXME
|
b"block" => SyntaxShape::Block(None), //FIXME: Blocks should have known output types
|
||||||
b"cond" => SyntaxShape::RowCondition,
|
b"cond" => SyntaxShape::RowCondition,
|
||||||
b"operator" => SyntaxShape::Operator,
|
b"operator" => SyntaxShape::Operator,
|
||||||
b"math" => SyntaxShape::MathExpression,
|
b"math" => SyntaxShape::MathExpression,
|
||||||
@ -2161,7 +2160,7 @@ pub fn parse_signature_helper(
|
|||||||
let (syntax_shape, err) =
|
let (syntax_shape, err) =
|
||||||
parse_shape_name(working_set, contents, span);
|
parse_shape_name(working_set, contents, span);
|
||||||
error = error.or(err);
|
error = error.or(err);
|
||||||
//TODO check if we're replacing one already
|
//TODO check if we're replacing a custom parameter already
|
||||||
match last {
|
match last {
|
||||||
Arg::Positional(PositionalArg { shape, var_id, .. }, ..) => {
|
Arg::Positional(PositionalArg { shape, var_id, .. }, ..) => {
|
||||||
working_set.set_variable_type(var_id.expect("internal error: all custom parameters must have var_ids"), syntax_shape.to_type());
|
working_set.set_variable_type(var_id.expect("internal error: all custom parameters must have var_ids"), syntax_shape.to_type());
|
||||||
@ -2555,7 +2554,7 @@ pub fn parse_block_expression(
|
|||||||
if let Some(signature) = signature {
|
if let Some(signature) = signature {
|
||||||
output.signature = signature;
|
output.signature = signature;
|
||||||
} else if let Some(last) = working_set.delta.scope.last() {
|
} else if let Some(last) = working_set.delta.scope.last() {
|
||||||
// FIXME: this only supports the top $it. Instead, we should look for a free $it in the expression.
|
// FIXME: this only supports the top $it. Is this sufficient?
|
||||||
|
|
||||||
if let Some(var_id) = last.get_var(b"$it") {
|
if let Some(var_id) = last.get_var(b"$it") {
|
||||||
let mut signature = Signature::new("");
|
let mut signature = Signature::new("");
|
||||||
|
@ -26,7 +26,7 @@ pub enum Expr {
|
|||||||
ValueWithUnit(Box<Expression>, Spanned<Unit>),
|
ValueWithUnit(Box<Expression>, Spanned<Unit>),
|
||||||
Filepath(String),
|
Filepath(String),
|
||||||
GlobPattern(String),
|
GlobPattern(String),
|
||||||
String(String), // FIXME: improve this in the future?
|
String(String),
|
||||||
CellPath(CellPath),
|
CellPath(CellPath),
|
||||||
FullCellPath(Box<FullCellPath>),
|
FullCellPath(Box<FullCellPath>),
|
||||||
Signature(Box<Signature>),
|
Signature(Box<Signature>),
|
||||||
|
@ -39,7 +39,7 @@ impl Expression {
|
|||||||
| Operator::In
|
| Operator::In
|
||||||
| Operator::NotIn => 80,
|
| Operator::NotIn => 80,
|
||||||
Operator::And => 50,
|
Operator::And => 50,
|
||||||
Operator::Or => 40, // TODO: should we have And and Or be different precedence?
|
Operator::Or => 40,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => 0,
|
_ => 0,
|
||||||
|
@ -25,8 +25,8 @@ impl EvaluationContext {
|
|||||||
// We need to make values concreate before we assign them to variables, as stream values
|
// We need to make values concreate before we assign them to variables, as stream values
|
||||||
// will drain and remain drained.
|
// will drain and remain drained.
|
||||||
//
|
//
|
||||||
// TODO: find a good home for this
|
// TODO: find a good home for converting a stream->list when storing into a variable
|
||||||
// TODO: add ctrl-c support
|
// TODO: add ctrl-c support when setting a var
|
||||||
|
|
||||||
let value = match value {
|
let value = match value {
|
||||||
Value::Stream { stream, span } => Value::List {
|
Value::Stream { stream, span } => Value::List {
|
||||||
|
@ -108,7 +108,7 @@ impl SyntaxShape {
|
|||||||
SyntaxShape::Boolean => Type::Bool,
|
SyntaxShape::Boolean => Type::Bool,
|
||||||
SyntaxShape::Signature => Type::Unknown,
|
SyntaxShape::Signature => Type::Unknown,
|
||||||
SyntaxShape::String => Type::String,
|
SyntaxShape::String => Type::String,
|
||||||
SyntaxShape::Table => Type::List(Box::new(Type::Unknown)), // FIXME
|
SyntaxShape::Table => Type::List(Box::new(Type::Unknown)), // FIXME: Tables should have better types
|
||||||
SyntaxShape::VarWithOptType => Type::Unknown,
|
SyntaxShape::VarWithOptType => Type::Unknown,
|
||||||
SyntaxShape::Variable => Type::Unknown,
|
SyntaxShape::Variable => Type::Unknown,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ impl Range {
|
|||||||
operator: &RangeOperator,
|
operator: &RangeOperator,
|
||||||
) -> Result<Range, ShellError> {
|
) -> Result<Range, ShellError> {
|
||||||
// Select from & to values if they're not specified
|
// Select from & to values if they're not specified
|
||||||
// TODO: Replace the placeholder values with proper min/max based on data type
|
// TODO: Replace the placeholder values with proper min/max for range based on data type
|
||||||
let from = if let Value::Nothing { .. } = from {
|
let from = if let Value::Nothing { .. } = from {
|
||||||
Value::Int {
|
Value::Int {
|
||||||
val: 0i64,
|
val: 0i64,
|
||||||
|
@ -62,7 +62,6 @@ impl<'de> Deserialize<'de> for ValueStream {
|
|||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
// FIXME: implement these
|
|
||||||
deserializer.deserialize_seq(MySeqVisitor)
|
deserializer.deserialize_seq(MySeqVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user