mirror of
https://github.com/nushell/nushell.git
synced 2024-11-08 01:24:38 +01:00
commit
25c7d8ead6
39
.github/workflows/ci.yml
vendored
Normal file
39
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
on: push
|
||||
|
||||
name: Continuous integration
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
@ -26,7 +26,7 @@ impl Command for Do {
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
let block = &call.positional[0];
|
||||
|
||||
let out = eval_expression(context, &block)?;
|
||||
let out = eval_expression(context, block)?;
|
||||
|
||||
match out {
|
||||
Value::Block { val: block_id, .. } => {
|
||||
|
@ -48,7 +48,7 @@ impl Command for Each {
|
||||
let block = engine_state.get_block(block);
|
||||
|
||||
let state = context.enter_scope();
|
||||
state.add_var(var_id, x.clone());
|
||||
state.add_var(var_id, x);
|
||||
|
||||
//FIXME: DON'T UNWRAP
|
||||
eval_block(&state, block, Value::nothing()).unwrap()
|
||||
@ -63,7 +63,7 @@ impl Command for Each {
|
||||
let block = engine_state.get_block(block);
|
||||
|
||||
let state = context.enter_scope();
|
||||
state.add_var(var_id, x.clone());
|
||||
state.add_var(var_id, x);
|
||||
|
||||
//FIXME: DON'T UNWRAP
|
||||
eval_block(&state, block, Value::nothing()).unwrap()
|
||||
|
@ -60,7 +60,7 @@ impl Command for For {
|
||||
let block = engine_state.get_block(block);
|
||||
|
||||
let state = context.enter_scope();
|
||||
state.add_var(var_id, x.clone());
|
||||
state.add_var(var_id, x);
|
||||
|
||||
//FIXME: DON'T UNWRAP
|
||||
eval_block(&state, block, Value::nothing()).unwrap()
|
||||
@ -76,7 +76,7 @@ impl Command for For {
|
||||
let block = engine_state.get_block(block);
|
||||
|
||||
let state = context.enter_scope();
|
||||
state.add_var(var_id, x.clone());
|
||||
state.add_var(var_id, x);
|
||||
|
||||
//FIXME: DON'T UNWRAP
|
||||
eval_block(&state, block, Value::nothing()).unwrap()
|
||||
|
@ -247,12 +247,10 @@ fn calculate_end_span(
|
||||
&& spans.len() > (signature.required_positional.len() - positional_idx)
|
||||
{
|
||||
spans.len() - (signature.required_positional.len() - positional_idx - 1)
|
||||
} else if signature.num_positionals_after(positional_idx) == 0 {
|
||||
spans.len()
|
||||
} else {
|
||||
if signature.num_positionals_after(positional_idx) == 0 {
|
||||
spans.len()
|
||||
} else {
|
||||
spans_idx + 1
|
||||
}
|
||||
spans_idx + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -496,7 +494,7 @@ pub fn parse_call(
|
||||
let cmd_start = pos;
|
||||
|
||||
if expand_aliases {
|
||||
if let Some(expansion) = working_set.find_alias(&name) {
|
||||
if let Some(expansion) = working_set.find_alias(name) {
|
||||
let orig_span = spans[pos];
|
||||
//let mut spans = spans.to_vec();
|
||||
let mut new_spans: Vec<Span> = vec![];
|
||||
@ -992,7 +990,7 @@ pub fn parse_string(
|
||||
|
||||
//TODO: Handle error case
|
||||
pub fn parse_shape_name(
|
||||
working_set: &StateWorkingSet,
|
||||
_working_set: &StateWorkingSet,
|
||||
bytes: &[u8],
|
||||
span: Span,
|
||||
) -> (SyntaxShape, Option<ParseError>) {
|
||||
@ -1018,7 +1016,7 @@ pub fn parse_shape_name(
|
||||
(result, None)
|
||||
}
|
||||
|
||||
pub fn parse_type(working_set: &StateWorkingSet, bytes: &[u8]) -> Type {
|
||||
pub fn parse_type(_working_set: &StateWorkingSet, bytes: &[u8]) -> Type {
|
||||
if bytes == b"int" {
|
||||
Type::Int
|
||||
} else {
|
||||
@ -1479,7 +1477,7 @@ pub fn parse_list_expression(
|
||||
expr: Expr::List(args),
|
||||
span,
|
||||
ty: Type::List(Box::new(if let Some(ty) = contained_type {
|
||||
ty.clone()
|
||||
ty
|
||||
} else {
|
||||
Type::Unknown
|
||||
})),
|
||||
@ -2001,14 +1999,11 @@ pub fn parse_def_predecl(working_set: &mut StateWorkingSet, spans: &[Span]) {
|
||||
let signature = sig.as_signature();
|
||||
working_set.exit_scope();
|
||||
|
||||
match (name, signature) {
|
||||
(Some(name), Some(mut signature)) => {
|
||||
signature.name = name;
|
||||
let decl = signature.predeclare();
|
||||
if let (Some(name), Some(mut signature)) = (name, signature) {
|
||||
signature.name = name;
|
||||
let decl = signature.predeclare();
|
||||
|
||||
working_set.add_decl(decl);
|
||||
}
|
||||
_ => {}
|
||||
working_set.add_decl(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool {
|
||||
}
|
||||
|
||||
pub fn math_result_type(
|
||||
working_set: &StateWorkingSet,
|
||||
_working_set: &StateWorkingSet,
|
||||
lhs: &mut Expression,
|
||||
op: &mut Expression,
|
||||
rhs: &mut Expression,
|
||||
|
@ -119,6 +119,7 @@ impl EngineState {
|
||||
.expect("internal error: missing variable")
|
||||
}
|
||||
|
||||
#[allow(clippy::borrowed_box)]
|
||||
pub fn get_decl(&self, decl_id: DeclId) -> &Box<dyn Command> {
|
||||
self.decls
|
||||
.get(decl_id)
|
||||
@ -460,6 +461,7 @@ impl<'a> StateWorkingSet<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::borrowed_box)]
|
||||
pub fn get_decl(&self, decl_id: DeclId) -> &Box<dyn Command> {
|
||||
let num_permanent_decls = self.permanent_state.num_decls();
|
||||
if decl_id < num_permanent_decls {
|
||||
|
@ -249,9 +249,8 @@ impl Signature {
|
||||
|
||||
pub fn num_positionals_after(&self, idx: usize) -> usize {
|
||||
let mut total = 0;
|
||||
let mut curr = 0;
|
||||
|
||||
for positional in &self.required_positional {
|
||||
for (curr, positional) in self.required_positional.iter().enumerate() {
|
||||
match positional.shape {
|
||||
SyntaxShape::Keyword(..) => {
|
||||
// Keywords have a required argument, so account for that
|
||||
@ -265,7 +264,6 @@ impl Signature {
|
||||
}
|
||||
}
|
||||
}
|
||||
curr += 1;
|
||||
}
|
||||
total
|
||||
}
|
||||
|
@ -9,13 +9,11 @@ pub struct ValueStream(pub Rc<RefCell<dyn Iterator<Item = Value>>>);
|
||||
|
||||
impl ValueStream {
|
||||
pub fn into_string(self) -> String {
|
||||
let val: Vec<Value> = self.collect();
|
||||
format!(
|
||||
"[{}]",
|
||||
val.into_iter()
|
||||
.map(|x| x.into_string())
|
||||
self.map(|x| x.into_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ".into())
|
||||
.join(", ")
|
||||
)
|
||||
}
|
||||
|
||||
@ -59,23 +57,21 @@ pub struct RowStream(Rc<RefCell<dyn Iterator<Item = Vec<Value>>>>);
|
||||
|
||||
impl RowStream {
|
||||
pub fn into_string(self, headers: Vec<String>) -> String {
|
||||
let val: Vec<Vec<Value>> = self.collect();
|
||||
format!(
|
||||
"[{}]\n[{}]",
|
||||
headers
|
||||
.iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ".into()),
|
||||
val.into_iter()
|
||||
.map(|x| {
|
||||
x.into_iter()
|
||||
.map(|x| x.into_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ".into())
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n")
|
||||
.join(", "),
|
||||
self.map(|x| {
|
||||
x.into_iter()
|
||||
.map(|x| x.into_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ")
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user