├── .gitignore ├── src ├── diags │ ├── mod.rs │ └── diagnostics.rs └── main.rs ├── .gitattributes ├── Cargo.toml ├── README.md ├── LICENSE ├── nushell.pest ├── Cargo.lock └── example.nu /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /src/diags/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod diagnostics; 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Example of a `.gitattributes` file which reclassifies `.nu` files as Nushell: 2 | *.nu linguist-language=Nushell 3 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-grammar" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | pest = "2.0" 8 | pest_derive = "2.0" 9 | nu-protocol = "0.68.1" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grammar 2 | Working on simplifications of Nushell's grammar towards better parse-ability 3 | 4 | Note: this grammar also includes some experimental syntax changes we're considering for future Nushell releases 5 | 6 | ## Try it out 7 | 8 | 1. Paste grammar to https://pest.rs/#editor 9 | 2. Select your starting point in the drop-down menu (e.g., "program") 10 | 3. Type your code and see the parsed abstract syntax tree (AST) 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Nushell Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod diags; 2 | 3 | use diags::diagnostics::{help, parse_command_line_args, print_pair}; 4 | use nu_protocol::{ 5 | ast::{Expr, Expression, Operator}, 6 | Span, Type, 7 | }; 8 | use pest::{iterators::Pair, Parser}; 9 | use std::error::Error; 10 | 11 | #[macro_use] 12 | extern crate pest_derive; 13 | 14 | #[derive(Parser)] 15 | #[grammar = "../nushell.pest"] 16 | struct NuParser; 17 | 18 | fn main() -> Result<(), Box> { 19 | let args = parse_command_line_args()?; 20 | 21 | let unparsed_input = if args.file_mode { 22 | std::fs::read_to_string(args.file_name)? 23 | } else if args.string_mode { 24 | args.string 25 | } else { 26 | help(); 27 | return Err("No input file or string")?; 28 | }; 29 | 30 | let pairs = NuParser::parse(args.rule, &unparsed_input)?; 31 | 32 | if args.expression_mode { 33 | for pair in pairs { 34 | let output = convert_to_nu_expression(pair); 35 | println!("{:?}", output); 36 | } 37 | } else if args.diagnostic_mode { 38 | for pair in pairs { 39 | print_pair(pair, 0); 40 | } 41 | } else { 42 | help(); 43 | return Err("No output mode specified. Please supply -e or -d")?; 44 | } 45 | 46 | Ok(()) 47 | } 48 | 49 | fn convert_to_nu_expression(pair: Pair) -> Box { 50 | let span = pair.as_span(); 51 | let token = pair.as_rule(); 52 | 53 | let span = Span { 54 | start: span.start(), 55 | end: span.end(), 56 | }; 57 | 58 | let string = pair.as_str().to_string(); 59 | 60 | let mut v = vec![]; 61 | for pair in pair.into_inner() { 62 | let operand = convert_to_nu_expression(pair); 63 | v.push(operand); 64 | } 65 | 66 | match token { 67 | Rule::plus_expr => { 68 | if v.len() == 1 { 69 | return v.pop().unwrap(); 70 | } 71 | //FIXME: remove clones 72 | let expr = Expr::BinaryOp(v[0].clone(), v[1].clone(), v[2].clone()); 73 | 74 | Box::new(Expression { 75 | expr, 76 | span, 77 | custom_completion: None, 78 | ty: Type::Any, 79 | }) 80 | } 81 | Rule::mul_expr => { 82 | if v.len() == 1 { 83 | return v.pop().unwrap(); 84 | } 85 | 86 | //FIXME: remove clones 87 | let expr = Expr::BinaryOp(v[0].clone(), v[1].clone(), v[2].clone()); 88 | 89 | Box::new(Expression { 90 | expr, 91 | span, 92 | custom_completion: None, 93 | ty: Type::Any, 94 | }) 95 | } 96 | Rule::pow_expr => { 97 | if v.len() == 1 { 98 | return v.pop().unwrap(); 99 | } 100 | 101 | //FIXME: remove clones 102 | let expr = Expr::BinaryOp(v[0].clone(), v[1].clone(), v[2].clone()); 103 | 104 | Box::new(Expression { 105 | expr, 106 | span, 107 | custom_completion: None, 108 | ty: Type::Any, 109 | }) 110 | } 111 | Rule::int => { 112 | //FIXME: remove clones 113 | let int_val = string.parse::().unwrap(); 114 | let expr = Expr::Int(int_val); 115 | 116 | Box::new(Expression { 117 | expr, 118 | span, 119 | custom_completion: None, 120 | ty: Type::Any, 121 | }) 122 | } 123 | Rule::float => { 124 | //FIXME: remove clones 125 | let float_val = string.parse::().unwrap(); 126 | let expr = Expr::Float(float_val); 127 | 128 | Box::new(Expression { 129 | expr, 130 | span, 131 | custom_completion: None, 132 | ty: Type::Any, 133 | }) 134 | } 135 | Rule::dec_int => { 136 | //FIXME: remove clones 137 | let int_val = string.parse::().unwrap(); 138 | let expr = Expr::Int(int_val); 139 | 140 | Box::new(Expression { 141 | expr, 142 | span, 143 | custom_completion: None, 144 | ty: Type::Any, 145 | }) 146 | } 147 | Rule::plus_op => { 148 | if string == "+" { 149 | Box::new(Expression { 150 | expr: Expr::Operator(Operator::Plus), 151 | span, 152 | custom_completion: None, 153 | ty: Type::Any, 154 | }) 155 | } else if string == "-" { 156 | Box::new(Expression { 157 | expr: Expr::Operator(Operator::Minus), 158 | span, 159 | custom_completion: None, 160 | ty: Type::Any, 161 | }) 162 | } else { 163 | panic!("internal compiler error: operator not of supported set") 164 | } 165 | } 166 | Rule::mul_op => { 167 | if string == "*" { 168 | Box::new(Expression { 169 | expr: Expr::Operator(Operator::Multiply), 170 | span, 171 | custom_completion: None, 172 | ty: Type::Any, 173 | }) 174 | } else if string == "/" { 175 | Box::new(Expression { 176 | expr: Expr::Operator(Operator::Divide), 177 | span, 178 | custom_completion: None, 179 | ty: Type::Any, 180 | }) 181 | } else if string == "//" { 182 | Box::new(Expression { 183 | expr: Expr::Operator(Operator::FloorDivision), 184 | span, 185 | custom_completion: None, 186 | ty: Type::Any, 187 | }) 188 | } else { 189 | panic!("internal compiler error: operator not of supported set") 190 | } 191 | } 192 | Rule::double_quote_string_inner => { 193 | // TODO: unescape the string 194 | Box::new(Expression { 195 | expr: Expr::String(string), 196 | span, 197 | custom_completion: None, 198 | ty: Type::String, 199 | }) 200 | } 201 | Rule::string => { 202 | if v.len() == 1 { 203 | return v.pop().unwrap(); 204 | } 205 | panic!("internal compiler error: internal string incomplete") 206 | } 207 | Rule::double_quote_string => { 208 | if v.len() == 1 { 209 | return v.pop().unwrap(); 210 | } 211 | panic!("internal compiler error: internal string incomplete") 212 | } 213 | x => { 214 | panic!("UNMATCHED: {:#?}", x) 215 | } 216 | } 217 | 218 | // Box::new(Expression { 219 | // expr: Expr::Nothing, 220 | // span, 221 | // custom_completion: None, 222 | // ty: Type::Nothing, 223 | // }) 224 | } 225 | -------------------------------------------------------------------------------- /nushell.pest: -------------------------------------------------------------------------------- 1 | // Primitives 2 | 3 | hex_int = @{ "0x" ~ ASCII_HEX_DIGIT+ } 4 | oct_int = @{ "0o" ~ ASCII_OCT_DIGIT+ } 5 | bin_int = @{ "0b" ~ ASCII_BIN_DIGIT+ } 6 | dec_int = @{ "-"? ~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) } 7 | int = { hex_int | oct_int | bin_int | dec_int } 8 | 9 | float = @{ 10 | "-"? 11 | ~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) 12 | ~ "." 13 | ~ ASCII_DIGIT* 14 | ~ (^"e" ~ ("+" | "-")? ~ ASCII_DIGIT+)? 15 | } 16 | 17 | string = { double_quote_string | single_quote_string | backtick_string | interpolated_string } 18 | double_quote_string = ${ "\"" ~ double_quote_string_inner ~ "\"" } 19 | double_quote_string_inner = @{ double_quote_string_char* } 20 | double_quote_string_char = { 21 | !("\"" | "\\") ~ ANY 22 | | "\\" ~ ("\"" | "\\" | "/" | "a" | "b" | "e" | "f" | "n" | "r" | "t" | "(" | ")" | "{" | "}" | "[" | "]" | "$" | "^" | "#" | "|" | "~") 23 | | "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4}) 24 | } 25 | 26 | interpolated_string = { double_quote_interpolated_string | single_quote_interpolated_string } 27 | double_quote_interpolated_string = ${ "$\"" ~ double_quote_string_inner ~ "\"" } 28 | single_quote_interpolated_string = ${ "$'" ~ single_quote_string_inner ~ "'" } 29 | 30 | single_quote_string = ${ "'" ~ single_quote_string_inner ~ "'" } 31 | single_quote_string_inner = @{ single_quote_string_char* } 32 | single_quote_string_char = { 33 | !("'") ~ ANY 34 | } 35 | 36 | backtick_string = ${ "`" ~ backtick_string_inner ~ "`" } 37 | backtick_string_inner = @{ backtick_string_char* } 38 | backtick_string_char = { 39 | !("`") ~ ANY 40 | } 41 | 42 | filesize = @{ dec_int ~ (^"b" | ^"kb" | ^"kib" | ^"mb" | ^"mib" | ^"gb" | ^"gib" | ^"tb" | ^"tib" | ^"pb" | ^"pib" | ^"eb" | ^"eib" | ^"zb" | ^"zib") } 43 | duration = @{ dec_int ~ (^"ns" | ^"us" | ^"ms" | ^"sec" | ^"min" | ^"hr" | ^"day" | ^"wk" | ^"month" | ^"yr" | ^"dec")} 44 | 45 | unit = { filesize | duration } 46 | 47 | binary_data = { binary_data_hex | binary_data_oct | binary_data_bin } 48 | binary_data_hex = @{ "0x[" ~ (ASCII_HEX_DIGIT | sp)+ ~ "]" } 49 | binary_data_oct = @{ "0o[" ~ (ASCII_OCT_DIGIT | sp)+ ~ "]" } 50 | binary_data_bin = @{ "0b[" ~ (ASCII_BIN_DIGIT | sp)+ ~ "]" } 51 | 52 | 53 | // Compound values 54 | 55 | array = { 56 | "[" ~ "]" | 57 | "[" ~ ws* ~ bare_value ~ ((ws | ",")+ ~ bare_value)* ~ ws* ~ "]" 58 | } 59 | 60 | table = { 61 | "["~ ws* ~ array ~ ws* ~ ";" ~ ws* ~ (array | ws)+ ~ "]" 62 | } 63 | record = { 64 | "{" ~ ws* ~ "}" | 65 | "{" ~ ws* ~ pair ~ (ws* ~ "," ~ ws* ~ pair)* ~ ws* ~ "}" 66 | } 67 | pair = { label ~ ws* ~ ":" ~ ws* ~ bare_value } 68 | label = { string | ident } 69 | 70 | ident_char = {!(" " | "\t" | "|" | "$" | "{" | "}" | "(" | ")" | "[" | "]" | "\r" | "\n" | "." | "," | ":") ~ ANY} 71 | ident = @{ ident_char+ } 72 | 73 | range_value = ${ int | float | variable | paren_expr } 74 | range = @{ (range_value ~ ".." ~ range_value) | (range_value ~ ".." ) | (".." ~ range_value) } 75 | 76 | // Date & Time 77 | // Borrowed from here and tweaked https://github.com/pest-parser/pest/blob/master/grammars/src/grammars/toml.pest 78 | 79 | //ISO8601 Format 80 | //d"1994-11-05T08:15:30.123456789Z" 81 | //d"1994-11-05T08:15:30.123456789+01:00" 82 | //d"1994-11-05T08:15:30.123456789-01:00" 83 | //d"1994-11-05T08:15:30" 84 | //d"1994-11-05T08:15:30Z" 85 | //d"1994-11-05T01:01:01+03:00" 86 | //d"1994-11-05" 87 | 88 | //TODO: Support other date formats? Support AM/PM? Match what nushell supports? 89 | 90 | date_time = ${ full_date ~ "T" ~ full_time } 91 | local_date_time = ${ full_date ~ "T" ~ partial_time } 92 | 93 | quotes = ${ ("\"" | "'" | "`") } 94 | date_sigil = ${ "d" ~ quotes } 95 | partial_time = ${ time_hour ~ ":" ~ time_minute ~ ":" ~ time_second ~ time_secfrac? } 96 | full_date = ${ date_sigil ~ date_fullyear ~ "-" ~ date_month ~ "-" ~ date_mday ~ quotes? } 97 | full_time = ${ partial_time ~ time_offset? ~ quotes } 98 | 99 | date_fullyear = @{ ASCII_DIGIT{4} } 100 | date_month = @{ ASCII_DIGIT{2} } 101 | date_mday = @{ ASCII_DIGIT{2} } 102 | 103 | time_hour = @{ ASCII_DIGIT{2} } 104 | time_minute = @{ ASCII_DIGIT{2} } 105 | time_second = @{ ASCII_DIGIT{2} } 106 | time_secfrac = @{ "." ~ ASCII_DIGIT+ } 107 | time_offset = ${ "Z" | ("+" | "-") ~ time_hour ~ ":" ~ time_minute } 108 | 109 | date_or_datetime = { date_time | local_date_time | full_date ~ full_time? } 110 | 111 | // Bare word forms 112 | 113 | bare_char = _{!(" " | "\t" | "|" | "$" | "{" | "}" | "(" | ")" | "\r" | "\n") ~ ANY} 114 | bare_follow_char = _{!(" " | "\t" | "|" | "$" | "(" | ")" | "\r" | "\n") ~ ANY} 115 | bare_string = @{ bare_char ~ bare_follow_char* } 116 | bare_word = @{ (ASCII_ALPHANUMERIC | "-" | "." | "_")+ } 117 | bare_value = { value | bare_word } 118 | 119 | 120 | // Variables 121 | 122 | variable_char = {!(" " | "\t" | "|" | "$" | "{" | "}" | "(" | ")" | "[" | "]" | "\r" | "\n" | "." | ":" | "+" | "-" | "/" | "*") ~ ANY} 123 | variable_name = @{ variable_char+ } 124 | variable = { "$" ~ variable_name } 125 | 126 | 127 | // Math expression 128 | 129 | comp_op_word = { "starts-with" | "ends-with" | "in" | "not-in" } 130 | comp_op = { "!~" | "=~" | "<=" | ">=" | "<" | ">" | "!=" | "==" } 131 | 132 | shift_op_word = { "bit-shl" | "bit-shr" } 133 | 134 | plus_op = { "+" | "-" } 135 | 136 | mul_op_word = { "mod" } 137 | mul_op = { (!"**" ~ "*") | "//" | "/" } 138 | 139 | or_expr = { and_expr ~ (((sp+ ~ "or" ~ sp+) | (sp* ~ "||" ~ sp*)) ~ and_expr)* } 140 | and_expr = { bitor_expr ~ (((sp+ ~ "and" ~ sp+) | (sp* ~ "&&" ~ sp*)) ~ bitor_expr)* } 141 | bitor_expr = { bitxor_expr ~ ((sp+ ~ "bit-or" ~ sp+) ~ bitxor_expr)* } 142 | bitxor_expr = { bitand_expr ~ ((sp+ ~ "bit-xor" ~ sp+) ~ bitand_expr)* } 143 | bitand_expr = { comp_expr ~ ((sp+ ~ "bit-and" ~ sp+) ~ comp_expr)* } 144 | comp_expr = { shift_expr ~ (((sp* ~ comp_op ~ sp*) | (sp+ ~ comp_op_word ~ sp+)) ~ shift_expr)* } 145 | shift_expr = { plus_expr ~ (((sp+ ~ shift_op_word ~ sp+)) ~ plus_expr)* } 146 | plus_expr = { mul_expr ~ (sp* ~ plus_op ~ sp* ~ mul_expr)* } 147 | mul_expr = { pow_expr ~ (((sp* ~ mul_op ~ sp*) | (sp+ ~ mul_op_word ~ sp+)) ~ pow_expr)* } 148 | pow_expr = { value ~ ((sp* ~ "**" ~ sp*) ~ value)* } 149 | 150 | // Row conditions 151 | 152 | row_value = { value | ident } 153 | row_or_expr = { row_and_expr ~ (((sp+ ~ "or" ~ sp+) | (sp* ~ "||" ~ sp*)) ~ row_and_expr)* } 154 | row_and_expr = { row_bitor_expr ~ (((sp+ ~ "and" ~ sp+) | (sp* ~ "&&" ~ sp*)) ~ row_bitor_expr)* } 155 | row_bitor_expr = { row_bitxor_expr ~ ((sp+ ~ "bit-or" ~ sp+) ~ row_bitxor_expr)* } 156 | row_bitxor_expr = { row_bitand_expr ~ ((sp+ ~ "bit-xor" ~ sp+) ~ row_bitand_expr)* } 157 | row_bitand_expr = { row_comp_expr ~ ((sp+ ~ "bit-and" ~ sp+) ~ row_comp_expr)* } 158 | row_comp_expr = { row_shift_expr ~ (((sp* ~ comp_op ~ sp*) | (sp+ ~ comp_op_word ~ sp+)) ~ row_shift_expr)* } 159 | row_shift_expr = { row_plus_expr ~ (sp+ ~ shift_op_word ~ sp+ ~ row_plus_expr)* } 160 | row_plus_expr = { row_mul_expr ~ (sp* ~ plus_op ~ sp* ~ row_mul_expr)* } 161 | row_mul_expr = { row_pow_expr ~ (((sp* ~ mul_op ~ sp*) | (sp+ ~ mul_op_word ~ sp+)) ~ row_pow_expr)* } 162 | row_pow_expr = { row_value ~ (sp* ~ "**" ~ sp* ~ row_value)* } 163 | 164 | row_condition = { row_or_expr } 165 | 166 | 167 | // Expression values 168 | 169 | expr = { or_expr } 170 | 171 | assignment_operator = { "+=" | "-=" | "*=" | "/=" | "=" } 172 | assignment = { variable ~ ws* ~ assignment_operator ~ ws* ~ expr } 173 | 174 | paren_expr = { "(" ~ ws* ~ pipeline ~ ws* ~ ")" } 175 | 176 | pathed_value = { (record | table | array | variable | closure | block | paren_expr | traditional_call) ~ (("." ~ ident) | ("[" ~ ws* ~ expr ~ ws* ~ "]"))* } 177 | 178 | value = _{ binary_data | range | unit | float | int | string | pathed_value | date_or_datetime | "true" | "false" | "null" } 179 | 180 | // Code blocks 181 | 182 | block = { "{" ~ code_block ~ "}" } 183 | 184 | closure_args = { "|" ~ sp* ~ param* ~ sp* ~ "|"} 185 | closure = { "{" ~ ws* ~ closure_args ~ code_block ~ "}" } 186 | 187 | param = { ident ~ (sp* ~ ":" ~ sp* ~ ident)? ~ sp* ~ ("=" ~ sp* ~ value)? ~ sp* ~ ","? ~ sp? } 188 | params = { ("(" ~ ws* ~ param* ~ ws* ~ ")") | ("[" ~ ws* ~ param* ~ ws* ~ "]") } 189 | 190 | // Builtins 191 | 192 | where_command = { "where" ~ row_condition } 193 | def_command = { "def" ~ sp+ ~ ident ~ sp* ~ params ~ sp* ~ block } 194 | def_env_command = { "def-env" ~ sp+ ~ ident ~ sp* ~ params ~ sp* ~ block } 195 | if_command = { "if" ~ sp+ ~ expr ~ sp* ~ block ~ (sp+ ~ "else" ~ sp+ ~ if_command)* ~ (sp+ ~ "else" ~ sp* ~ block)? } 196 | for_command = { "for" ~ sp+ ~ ident ~ sp+ ~ "in" ~ sp+ ~ ( range | array | ident | variable ) ~ sp+ ~ block } 197 | while_command = { "while" ~ sp+ ~ expr ~ sp+ ~ block } 198 | let_command = { "let" ~ sp+ ~ ident ~ sp* ~ "=" ~ sp* ~ pipeline } 199 | let_env_command = { "let-env" ~ sp+ ~ ident ~ sp* ~ "=" ~ sp* ~ pipeline } 200 | mut_command = { "mut" ~ sp+ ~ ident ~ sp* ~ "=" ~ sp* ~ pipeline } 201 | 202 | // Commands 203 | 204 | long_flag = @{ "--" ~ (ASCII_ALPHANUMERIC | "-")+ ~ ("=" ~ bare_string)? } 205 | short_flag = @{ "-" ~ ASCII_ALPHANUMERIC+ } 206 | flag = { short_flag | long_flag } 207 | 208 | user_command = { ident ~ (sp+ ~ (flag | value | bare_string ))* } 209 | 210 | break_command = { "break" } 211 | continue_command = { "continue" } 212 | return_command = { "return" ~ expr? } 213 | commands = _{ if_command | for_command | while_command | where_command | break_command | continue_command | return_command | expr | user_command } 214 | command = { !(("def" | "def-env") ~ sp+) ~ commands } 215 | 216 | unnamed_arg = !{ value } 217 | named_arg = !{ label ~ sp* ~ ":" ~ sp* ~ value } 218 | traditional_call_arg = !{ named_arg | unnamed_arg } 219 | arg_list = !{ traditional_call_arg ~ (sp* ~ "," ~ sp* ~ traditional_call_arg)* } 220 | traditional_call = ${ (ident ~ "(" ~ ws* ~ arg_list? ~ ws* ~ ")") } 221 | 222 | // Pipeline 223 | 224 | pipeline = { command ~ (ws* ~ (!"||" ~ "|") ~ ws* ~ command)* } 225 | 226 | // Program 227 | 228 | toplevel = _{ (def_command | def_env_command | let_command | let_env_command | mut_command | assignment | pipeline) } 229 | code_block = _{ (ws* ~ toplevel ~ sp* ~ ((nl | ";")+ ~ ws* ~ toplevel ~ sp*)*)? ~ ws*} 230 | program = _{ SOI ~ code_block ~ nl* ~ EOI } 231 | 232 | // Trivia 233 | 234 | COMMENT = _{ "#" ~ (!"\n" ~ ANY)* } 235 | nl = _{ "\r" | "\n" } 236 | ws = _{ nl | sp } 237 | sp = _{ " " | "\t" } -------------------------------------------------------------------------------- /src/diags/diagnostics.rs: -------------------------------------------------------------------------------- 1 | use crate::Rule; 2 | use pest::iterators::Pair; 3 | use std::error::Error; 4 | 5 | #[derive(Debug)] 6 | pub struct Args { 7 | pub file_mode: bool, 8 | pub file_name: String, 9 | pub string_mode: bool, 10 | pub string: String, 11 | pub diagnostic_mode: bool, 12 | pub expression_mode: bool, 13 | pub rule_mode: bool, 14 | pub rule: Rule, 15 | } 16 | 17 | pub fn parse_command_line_args() -> Result> { 18 | // Let's parse the command line arguments 19 | let mut file_mode = false; 20 | let mut file_name = String::new(); 21 | let mut string_mode = false; 22 | let mut string = String::new(); 23 | let mut diagnostic_mode = false; 24 | let mut expression_mode = false; 25 | let mut rule_mode = false; 26 | let mut rule = None; 27 | for argument in std::env::args().skip(1) { 28 | // println!("argument: {}", argument); 29 | if file_mode { 30 | file_name = argument; 31 | file_mode = false; 32 | } else if string_mode { 33 | string = argument; 34 | string_mode = false; 35 | } else if rule_mode { 36 | rule = get_rule(&argument); 37 | rule_mode = false; 38 | } else if argument == "-f" || argument == "--file" { 39 | file_mode = true; 40 | } else if argument == "-s" || argument == "--string" { 41 | string_mode = true; 42 | } else if argument == "-d" || argument == "--diagnostic" { 43 | diagnostic_mode = true; 44 | } else if argument == "-e" || argument == "--expression" { 45 | expression_mode = true; 46 | } else if argument == "-r" || argument == "--rule" { 47 | rule_mode = true; 48 | } else { 49 | return Err(format!("Unknown argument: {}", &argument))?; 50 | } 51 | } 52 | 53 | file_mode = !file_name.is_empty(); 54 | string_mode = !string.is_empty(); 55 | rule_mode = rule.is_some(); 56 | 57 | // A tiny bit of error checking 58 | if file_mode && string_mode { 59 | help(); 60 | return Err("Cannot use both file and string mode at the same time.")?; 61 | } 62 | 63 | if diagnostic_mode && expression_mode { 64 | help(); 65 | return Err("Cannot use both diagnostic and expression mode at the same time.")?; 66 | } 67 | 68 | let unwrapped_rule = match rule { 69 | Some(x) => x, 70 | None => Rule::program, 71 | }; 72 | 73 | let args = Args { 74 | file_mode, 75 | file_name, 76 | string_mode, 77 | string, 78 | diagnostic_mode, 79 | expression_mode, 80 | rule_mode, 81 | rule: unwrapped_rule, 82 | }; 83 | 84 | // println!("args: {:#?}", args); 85 | 86 | Ok(args) 87 | } 88 | 89 | pub fn help() { 90 | println!( 91 | "\nusage: 92 | -e - runs this program in nushell expression mode. 93 | -d - runs this program in diagnostic mode. 94 | -r - rule to test, specified like 'plus_expr'. 95 | -f - file mode: provide a file to parse. 96 | -s \"\" - string mode: provide a string to parse.\n 97 | 98 | example 1: 99 | cargo run 100 | (prints this help) 101 | 102 | example 2: 103 | cargo run -- -s \"10.4 + 9.6\" -e -r plus_expr 104 | runs in string mode, with the string \"10.4 + 9.6\", with output in expression mode, and with the rule plus_expr. 105 | 106 | example 3: 107 | cargo run -- -s \"10.4 + 9.6\" -d -r plus_expr 108 | runs in string mode, with the string \"10.4 + 9.6\", with output in diagnostic mode, and with the rule plus_expr. 109 | 110 | example 4: 111 | cargo run -- -s \"10.4 + 9.6\" -d 112 | runs in string mode, with the string \"10.4 + 9.6\", with output in diagnostic mode, and with the rule program (default). 113 | 114 | example 5: 115 | cargo r -- -f /path/to/file/example.nu -d 116 | runs in file mode, with the file example.nu, with the output in diagnostic mode, and with the rule program (default). 117 | " 118 | 119 | ); 120 | } 121 | 122 | pub fn print_pair(pair: Pair, indent: usize) { 123 | let span = pair.as_span(); 124 | let rule = pair.as_rule(); 125 | let text = pair.as_str(); 126 | println!( 127 | "{:indent$}Rule: \x1b[32m{:?}\x1b[0m, Text: \x1b[36m{}\x1b[0m, Span: {{ start: \x1b[35m{}\x1b[0m end: \x1b[35m{}\x1b[0m }}", 128 | "", 129 | rule, 130 | text, 131 | span.start(), 132 | span.end(), 133 | indent = indent 134 | ); 135 | 136 | for pair in pair.into_inner() { 137 | print_pair(pair, indent + 2); 138 | } 139 | } 140 | 141 | fn get_rule(rule_str: &str) -> Option { 142 | match rule_str { 143 | "and_expr" => Some(Rule::and_expr), 144 | "arg_list" => Some(Rule::arg_list), 145 | "array" => Some(Rule::array), 146 | "assignment" => Some(Rule::assignment), 147 | "assignment_operator" => Some(Rule::assignment_operator), 148 | "backtick_string" => Some(Rule::backtick_string), 149 | "backtick_string_char" => Some(Rule::backtick_string_char), 150 | "backtick_string_inner" => Some(Rule::backtick_string_inner), 151 | "bare_char" => Some(Rule::bare_char), 152 | "bare_follow_char" => Some(Rule::bare_follow_char), 153 | "bare_string" => Some(Rule::bare_string), 154 | "bare_value" => Some(Rule::bare_value), 155 | "bare_word" => Some(Rule::bare_word), 156 | "bin_int" => Some(Rule::bin_int), 157 | "binary_data" => Some(Rule::binary_data), 158 | "binary_data_bin" => Some(Rule::binary_data_bin), 159 | "binary_data_hex" => Some(Rule::binary_data_hex), 160 | "binary_data_oct" => Some(Rule::binary_data_oct), 161 | "bitand_expr" => Some(Rule::bitand_expr), 162 | "bitor_expr" => Some(Rule::bitor_expr), 163 | "bitxor_expr" => Some(Rule::bitxor_expr), 164 | "block" => Some(Rule::block), 165 | "break_command" => Some(Rule::break_command), 166 | "closure" => Some(Rule::closure), 167 | "closure_args" => Some(Rule::closure_args), 168 | "code_block" => Some(Rule::code_block), 169 | "command" => Some(Rule::command), 170 | "commands" => Some(Rule::commands), 171 | "COMMENT" => Some(Rule::COMMENT), 172 | "comp_expr" => Some(Rule::comp_expr), 173 | "comp_op" => Some(Rule::comp_op), 174 | "comp_op_word" => Some(Rule::comp_op_word), 175 | "continue_command" => Some(Rule::continue_command), 176 | "date_fullyear" => Some(Rule::date_fullyear), 177 | "date_mday" => Some(Rule::date_mday), 178 | "date_month" => Some(Rule::date_month), 179 | "date_or_datetime" => Some(Rule::date_or_datetime), 180 | "date_sigil" => Some(Rule::date_sigil), 181 | "date_time" => Some(Rule::date_time), 182 | "dec_int" => Some(Rule::dec_int), 183 | "def_command" => Some(Rule::def_command), 184 | "def_env_command" => Some(Rule::def_env_command), 185 | "double_quote_interpolated_string" => Some(Rule::double_quote_interpolated_string), 186 | "double_quote_string" => Some(Rule::double_quote_string), 187 | "double_quote_string_char" => Some(Rule::double_quote_string_char), 188 | "double_quote_string_inner" => Some(Rule::double_quote_string_inner), 189 | "duration" => Some(Rule::duration), 190 | "EOI" => Some(Rule::EOI), 191 | "expr" => Some(Rule::expr), 192 | "filesize" => Some(Rule::filesize), 193 | "flag" => Some(Rule::flag), 194 | "float" => Some(Rule::float), 195 | "for_command" => Some(Rule::for_command), 196 | "full_date" => Some(Rule::full_date), 197 | "full_time" => Some(Rule::full_time), 198 | "hex_int" => Some(Rule::hex_int), 199 | "ident" => Some(Rule::ident), 200 | "ident_char" => Some(Rule::ident_char), 201 | "if_command" => Some(Rule::if_command), 202 | "int" => Some(Rule::int), 203 | "interpolated_string" => Some(Rule::interpolated_string), 204 | "label" => Some(Rule::label), 205 | "let_command" => Some(Rule::let_command), 206 | "let_env_command" => Some(Rule::let_env_command), 207 | "local_date_time" => Some(Rule::local_date_time), 208 | "long_flag" => Some(Rule::long_flag), 209 | "mul_expr" => Some(Rule::mul_expr), 210 | "mul_op" => Some(Rule::mul_op), 211 | "mul_op_word" => Some(Rule::mul_op_word), 212 | "mut_command" => Some(Rule::mut_command), 213 | "named_arg" => Some(Rule::named_arg), 214 | "nl" => Some(Rule::nl), 215 | "oct_int" => Some(Rule::oct_int), 216 | "or_expr" => Some(Rule::or_expr), 217 | "pair" => Some(Rule::pair), 218 | "param" => Some(Rule::param), 219 | "params" => Some(Rule::params), 220 | "paren_expr" => Some(Rule::paren_expr), 221 | "partial_time" => Some(Rule::partial_time), 222 | "pathed_value" => Some(Rule::pathed_value), 223 | "pipeline" => Some(Rule::pipeline), 224 | "plus_expr" => Some(Rule::plus_expr), 225 | "plus_op" => Some(Rule::plus_op), 226 | "pow_expr" => Some(Rule::pow_expr), 227 | "program" => Some(Rule::program), 228 | "quotes" => Some(Rule::quotes), 229 | "range" => Some(Rule::range), 230 | "range_value" => Some(Rule::range_value), 231 | "record" => Some(Rule::record), 232 | "return_command" => Some(Rule::return_command), 233 | "row_and_expr" => Some(Rule::row_and_expr), 234 | "row_bitand_expr" => Some(Rule::row_bitand_expr), 235 | "row_bitor_expr" => Some(Rule::row_bitor_expr), 236 | "row_bitxor_expr" => Some(Rule::row_bitxor_expr), 237 | "row_comp_expr" => Some(Rule::row_comp_expr), 238 | "row_condition" => Some(Rule::row_condition), 239 | "row_mul_expr" => Some(Rule::row_mul_expr), 240 | "row_or_expr" => Some(Rule::row_or_expr), 241 | "row_plus_expr" => Some(Rule::row_plus_expr), 242 | "row_pow_expr" => Some(Rule::row_pow_expr), 243 | "row_shift_expr" => Some(Rule::row_shift_expr), 244 | "row_value" => Some(Rule::row_value), 245 | "shift_expr" => Some(Rule::shift_expr), 246 | "shift_op_word" => Some(Rule::shift_op_word), 247 | "short_flag" => Some(Rule::short_flag), 248 | "single_quote_interpolated_string" => Some(Rule::single_quote_interpolated_string), 249 | "single_quote_string" => Some(Rule::single_quote_string), 250 | "single_quote_string_char" => Some(Rule::single_quote_string_char), 251 | "single_quote_string_inner" => Some(Rule::single_quote_string_inner), 252 | "sp" => Some(Rule::sp), 253 | "string" => Some(Rule::string), 254 | "table" => Some(Rule::table), 255 | "time_hour" => Some(Rule::time_hour), 256 | "time_minute" => Some(Rule::time_minute), 257 | "time_offset" => Some(Rule::time_offset), 258 | "time_secfrac" => Some(Rule::time_secfrac), 259 | "time_second" => Some(Rule::time_second), 260 | "toplevel" => Some(Rule::toplevel), 261 | "traditional_call" => Some(Rule::traditional_call), 262 | "traditional_call_arg" => Some(Rule::traditional_call_arg), 263 | "unit" => Some(Rule::unit), 264 | "unnamed_arg" => Some(Rule::unnamed_arg), 265 | "user_command" => Some(Rule::user_command), 266 | "value" => Some(Rule::value), 267 | "variable" => Some(Rule::variable), 268 | "variable_char" => Some(Rule::variable_char), 269 | "variable_name" => Some(Rule::variable_name), 270 | "where_command" => Some(Rule::where_command), 271 | "while_command" => Some(Rule::while_command), 272 | "ws" => Some(Rule::ws), 273 | _ => None, 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.17.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "ahash" 22 | version = "0.7.6" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 25 | dependencies = [ 26 | "getrandom", 27 | "once_cell", 28 | "version_check", 29 | ] 30 | 31 | [[package]] 32 | name = "aho-corasick" 33 | version = "0.7.19" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" 36 | dependencies = [ 37 | "memchr", 38 | ] 39 | 40 | [[package]] 41 | name = "android_system_properties" 42 | version = "0.1.5" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 45 | dependencies = [ 46 | "libc", 47 | ] 48 | 49 | [[package]] 50 | name = "ansi_term" 51 | version = "0.12.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 54 | dependencies = [ 55 | "winapi", 56 | ] 57 | 58 | [[package]] 59 | name = "arrayvec" 60 | version = "0.4.12" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" 63 | dependencies = [ 64 | "nodrop", 65 | ] 66 | 67 | [[package]] 68 | name = "atty" 69 | version = "0.2.14" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 72 | dependencies = [ 73 | "hermit-abi", 74 | "libc", 75 | "winapi", 76 | ] 77 | 78 | [[package]] 79 | name = "autocfg" 80 | version = "1.1.0" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 83 | 84 | [[package]] 85 | name = "backtrace" 86 | version = "0.3.66" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" 89 | dependencies = [ 90 | "addr2line", 91 | "cc", 92 | "cfg-if", 93 | "libc", 94 | "miniz_oxide", 95 | "object", 96 | "rustc-demangle", 97 | ] 98 | 99 | [[package]] 100 | name = "bit-set" 101 | version = "0.5.3" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 104 | dependencies = [ 105 | "bit-vec", 106 | ] 107 | 108 | [[package]] 109 | name = "bit-vec" 110 | version = "0.6.3" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 113 | 114 | [[package]] 115 | name = "bitflags" 116 | version = "1.3.2" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 119 | 120 | [[package]] 121 | name = "block-buffer" 122 | version = "0.10.3" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" 125 | dependencies = [ 126 | "generic-array", 127 | ] 128 | 129 | [[package]] 130 | name = "bumpalo" 131 | version = "3.11.0" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" 134 | 135 | [[package]] 136 | name = "byte-unit" 137 | version = "4.0.14" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "95ebf10dda65f19ff0f42ea15572a359ed60d7fc74fdc984d90310937be0014b" 140 | dependencies = [ 141 | "utf8-width", 142 | ] 143 | 144 | [[package]] 145 | name = "cc" 146 | version = "1.0.73" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 149 | 150 | [[package]] 151 | name = "cfg-if" 152 | version = "1.0.0" 153 | source = "registry+https://github.com/rust-lang/crates.io-index" 154 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 155 | 156 | [[package]] 157 | name = "chrono" 158 | version = "0.4.22" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" 161 | dependencies = [ 162 | "iana-time-zone", 163 | "js-sys", 164 | "num-integer", 165 | "num-traits", 166 | "serde", 167 | "time", 168 | "wasm-bindgen", 169 | "winapi", 170 | ] 171 | 172 | [[package]] 173 | name = "chrono-humanize" 174 | version = "0.2.2" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "32dce1ea1988dbdf9f9815ff11425828523bd2a134ec0805d2ac8af26ee6096e" 177 | dependencies = [ 178 | "chrono", 179 | ] 180 | 181 | [[package]] 182 | name = "core-foundation-sys" 183 | version = "0.8.3" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 186 | 187 | [[package]] 188 | name = "cpufeatures" 189 | version = "0.2.5" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" 192 | dependencies = [ 193 | "libc", 194 | ] 195 | 196 | [[package]] 197 | name = "crossterm" 198 | version = "0.24.0" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "ab9f7409c70a38a56216480fba371ee460207dd8926ccf5b4160591759559170" 201 | dependencies = [ 202 | "bitflags", 203 | "crossterm_winapi", 204 | "libc", 205 | "mio", 206 | "parking_lot", 207 | "signal-hook", 208 | "signal-hook-mio", 209 | "winapi", 210 | ] 211 | 212 | [[package]] 213 | name = "crossterm_winapi" 214 | version = "0.9.0" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" 217 | dependencies = [ 218 | "winapi", 219 | ] 220 | 221 | [[package]] 222 | name = "crypto-common" 223 | version = "0.1.6" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 226 | dependencies = [ 227 | "generic-array", 228 | "typenum", 229 | ] 230 | 231 | [[package]] 232 | name = "cstr_core" 233 | version = "0.2.6" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956" 236 | dependencies = [ 237 | "cty", 238 | "memchr", 239 | ] 240 | 241 | [[package]] 242 | name = "ctor" 243 | version = "0.1.23" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb" 246 | dependencies = [ 247 | "quote", 248 | "syn", 249 | ] 250 | 251 | [[package]] 252 | name = "cty" 253 | version = "0.2.2" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" 256 | 257 | [[package]] 258 | name = "digest" 259 | version = "0.10.5" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" 262 | dependencies = [ 263 | "block-buffer", 264 | "crypto-common", 265 | ] 266 | 267 | [[package]] 268 | name = "dirs-next" 269 | version = "2.0.0" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" 272 | dependencies = [ 273 | "cfg-if", 274 | "dirs-sys-next", 275 | ] 276 | 277 | [[package]] 278 | name = "dirs-sys-next" 279 | version = "0.1.2" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" 282 | dependencies = [ 283 | "libc", 284 | "redox_users", 285 | "winapi", 286 | ] 287 | 288 | [[package]] 289 | name = "dunce" 290 | version = "1.0.2" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" 293 | 294 | [[package]] 295 | name = "erased-serde" 296 | version = "0.3.23" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | checksum = "54558e0ba96fbe24280072642eceb9d7d442e32c7ec0ea9e7ecd7b4ea2cf4e11" 299 | dependencies = [ 300 | "serde", 301 | ] 302 | 303 | [[package]] 304 | name = "fancy-regex" 305 | version = "0.10.0" 306 | source = "registry+https://github.com/rust-lang/crates.io-index" 307 | checksum = "0678ab2d46fa5195aaf59ad034c083d351377d4af57f3e073c074d0da3e3c766" 308 | dependencies = [ 309 | "bit-set", 310 | "regex", 311 | ] 312 | 313 | [[package]] 314 | name = "generic-array" 315 | version = "0.14.6" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 318 | dependencies = [ 319 | "typenum", 320 | "version_check", 321 | ] 322 | 323 | [[package]] 324 | name = "getrandom" 325 | version = "0.2.7" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" 328 | dependencies = [ 329 | "cfg-if", 330 | "libc", 331 | "wasi 0.11.0+wasi-snapshot-preview1", 332 | ] 333 | 334 | [[package]] 335 | name = "ghost" 336 | version = "0.1.6" 337 | source = "registry+https://github.com/rust-lang/crates.io-index" 338 | checksum = "eb19fe8de3ea0920d282f7b77dd4227aea6b8b999b42cdf0ca41b2472b14443a" 339 | dependencies = [ 340 | "proc-macro2", 341 | "quote", 342 | "syn", 343 | ] 344 | 345 | [[package]] 346 | name = "gimli" 347 | version = "0.26.2" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" 350 | 351 | [[package]] 352 | name = "hashbrown" 353 | version = "0.12.3" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 356 | dependencies = [ 357 | "ahash", 358 | ] 359 | 360 | [[package]] 361 | name = "hermit-abi" 362 | version = "0.1.19" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 365 | dependencies = [ 366 | "libc", 367 | ] 368 | 369 | [[package]] 370 | name = "iana-time-zone" 371 | version = "0.1.49" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "3bbaead50122b06e9a973ac20bc7445074d99ad9a0a0654934876908a9cec82c" 374 | dependencies = [ 375 | "android_system_properties", 376 | "core-foundation-sys", 377 | "js-sys", 378 | "wasm-bindgen", 379 | "winapi", 380 | ] 381 | 382 | [[package]] 383 | name = "indexmap" 384 | version = "1.9.1" 385 | source = "registry+https://github.com/rust-lang/crates.io-index" 386 | checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" 387 | dependencies = [ 388 | "autocfg", 389 | "hashbrown", 390 | "serde", 391 | ] 392 | 393 | [[package]] 394 | name = "inventory" 395 | version = "0.2.3" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "84344c6e0b90a9e2b6f3f9abe5cc74402684e348df7b32adca28747e0cef091a" 398 | dependencies = [ 399 | "ctor", 400 | "ghost", 401 | ] 402 | 403 | [[package]] 404 | name = "is_ci" 405 | version = "1.1.1" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" 408 | 409 | [[package]] 410 | name = "itoa" 411 | version = "0.4.8" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 414 | 415 | [[package]] 416 | name = "js-sys" 417 | version = "0.3.60" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" 420 | dependencies = [ 421 | "wasm-bindgen", 422 | ] 423 | 424 | [[package]] 425 | name = "lazy_static" 426 | version = "1.4.0" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 429 | 430 | [[package]] 431 | name = "libc" 432 | version = "0.2.133" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" 435 | 436 | [[package]] 437 | name = "linked-hash-map" 438 | version = "0.5.6" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" 441 | dependencies = [ 442 | "serde", 443 | ] 444 | 445 | [[package]] 446 | name = "lock_api" 447 | version = "0.4.9" 448 | source = "registry+https://github.com/rust-lang/crates.io-index" 449 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 450 | dependencies = [ 451 | "autocfg", 452 | "scopeguard", 453 | ] 454 | 455 | [[package]] 456 | name = "log" 457 | version = "0.4.17" 458 | source = "registry+https://github.com/rust-lang/crates.io-index" 459 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 460 | dependencies = [ 461 | "cfg-if", 462 | ] 463 | 464 | [[package]] 465 | name = "lscolors" 466 | version = "0.12.0" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "074bff749d092e2e818fe954952102f88e21f67fc69f4d350621aab15a1810f1" 469 | dependencies = [ 470 | "ansi_term", 471 | "crossterm", 472 | ] 473 | 474 | [[package]] 475 | name = "memchr" 476 | version = "2.5.0" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 479 | 480 | [[package]] 481 | name = "miette" 482 | version = "5.3.0" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "a28d6092d7e94a90bb9ea8e6c26c99d5d112d49dda2afdb4f7ea8cf09e1a5a6d" 485 | dependencies = [ 486 | "atty", 487 | "backtrace", 488 | "miette-derive", 489 | "once_cell", 490 | "owo-colors", 491 | "supports-color", 492 | "supports-hyperlinks", 493 | "supports-unicode", 494 | "terminal_size", 495 | "textwrap", 496 | "thiserror", 497 | "unicode-width", 498 | ] 499 | 500 | [[package]] 501 | name = "miette-derive" 502 | version = "5.3.0" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "4f2485ed7d1fe80704928e3eb86387439609bd0c6bb96db8208daa364cfd1e09" 505 | dependencies = [ 506 | "proc-macro2", 507 | "quote", 508 | "syn", 509 | ] 510 | 511 | [[package]] 512 | name = "miniz_oxide" 513 | version = "0.5.4" 514 | source = "registry+https://github.com/rust-lang/crates.io-index" 515 | checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" 516 | dependencies = [ 517 | "adler", 518 | ] 519 | 520 | [[package]] 521 | name = "mio" 522 | version = "0.8.4" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" 525 | dependencies = [ 526 | "libc", 527 | "log", 528 | "wasi 0.11.0+wasi-snapshot-preview1", 529 | "windows-sys", 530 | ] 531 | 532 | [[package]] 533 | name = "nodrop" 534 | version = "0.1.14" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" 537 | 538 | [[package]] 539 | name = "nu-grammar" 540 | version = "0.1.0" 541 | dependencies = [ 542 | "nu-protocol", 543 | "pest", 544 | "pest_derive", 545 | ] 546 | 547 | [[package]] 548 | name = "nu-json" 549 | version = "0.68.1" 550 | source = "registry+https://github.com/rust-lang/crates.io-index" 551 | checksum = "50419e7496da8e3a78be2791cab1ce7051dbf4f4ddceec6cb7c241d88a8c7a03" 552 | dependencies = [ 553 | "fancy-regex", 554 | "lazy_static", 555 | "linked-hash-map", 556 | "num-traits", 557 | "serde", 558 | ] 559 | 560 | [[package]] 561 | name = "nu-path" 562 | version = "0.68.1" 563 | source = "registry+https://github.com/rust-lang/crates.io-index" 564 | checksum = "9f300b72519e7fbd26e2705a77de4f3949225a9e3cbfdb1183e409cf598fb079" 565 | dependencies = [ 566 | "dirs-next", 567 | "dunce", 568 | "pwd", 569 | ] 570 | 571 | [[package]] 572 | name = "nu-protocol" 573 | version = "0.68.1" 574 | source = "registry+https://github.com/rust-lang/crates.io-index" 575 | checksum = "fcc0406451ef33ac8ab30e6809928975a8536a93da9ab8b834a4f9580aa08d96" 576 | dependencies = [ 577 | "byte-unit", 578 | "chrono", 579 | "chrono-humanize", 580 | "fancy-regex", 581 | "indexmap", 582 | "miette", 583 | "nu-json", 584 | "nu-path", 585 | "nu-utils", 586 | "num-format", 587 | "serde", 588 | "sys-locale", 589 | "thiserror", 590 | "typetag", 591 | ] 592 | 593 | [[package]] 594 | name = "nu-utils" 595 | version = "0.68.1" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "d465fec1c369d59c64a0c60ed7bab29f3ac15183f604ee9308c98e96eee33fc7" 598 | dependencies = [ 599 | "crossterm_winapi", 600 | "lscolors", 601 | "num-format", 602 | "sys-locale", 603 | ] 604 | 605 | [[package]] 606 | name = "num-format" 607 | version = "0.4.0" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" 610 | dependencies = [ 611 | "arrayvec", 612 | "itoa", 613 | ] 614 | 615 | [[package]] 616 | name = "num-integer" 617 | version = "0.1.45" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 620 | dependencies = [ 621 | "autocfg", 622 | "num-traits", 623 | ] 624 | 625 | [[package]] 626 | name = "num-traits" 627 | version = "0.2.15" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 630 | dependencies = [ 631 | "autocfg", 632 | ] 633 | 634 | [[package]] 635 | name = "object" 636 | version = "0.29.0" 637 | source = "registry+https://github.com/rust-lang/crates.io-index" 638 | checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" 639 | dependencies = [ 640 | "memchr", 641 | ] 642 | 643 | [[package]] 644 | name = "once_cell" 645 | version = "1.15.0" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" 648 | 649 | [[package]] 650 | name = "owo-colors" 651 | version = "3.5.0" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" 654 | 655 | [[package]] 656 | name = "parking_lot" 657 | version = "0.12.1" 658 | source = "registry+https://github.com/rust-lang/crates.io-index" 659 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 660 | dependencies = [ 661 | "lock_api", 662 | "parking_lot_core", 663 | ] 664 | 665 | [[package]] 666 | name = "parking_lot_core" 667 | version = "0.9.3" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" 670 | dependencies = [ 671 | "cfg-if", 672 | "libc", 673 | "redox_syscall", 674 | "smallvec", 675 | "windows-sys", 676 | ] 677 | 678 | [[package]] 679 | name = "pest" 680 | version = "2.3.1" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "cb779fcf4bb850fbbb0edc96ff6cf34fd90c4b1a112ce042653280d9a7364048" 683 | dependencies = [ 684 | "thiserror", 685 | "ucd-trie", 686 | ] 687 | 688 | [[package]] 689 | name = "pest_derive" 690 | version = "2.3.1" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "502b62a6d0245378b04ffe0a7fb4f4419a4815fce813bd8a0ec89a56e07d67b1" 693 | dependencies = [ 694 | "pest", 695 | "pest_generator", 696 | ] 697 | 698 | [[package]] 699 | name = "pest_generator" 700 | version = "2.3.1" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "451e629bf49b750254da26132f1a5a9d11fd8a95a3df51d15c4abd1ba154cb6c" 703 | dependencies = [ 704 | "pest", 705 | "pest_meta", 706 | "proc-macro2", 707 | "quote", 708 | "syn", 709 | ] 710 | 711 | [[package]] 712 | name = "pest_meta" 713 | version = "2.3.1" 714 | source = "registry+https://github.com/rust-lang/crates.io-index" 715 | checksum = "bcec162c71c45e269dfc3fc2916eaeb97feab22993a21bcce4721d08cd7801a6" 716 | dependencies = [ 717 | "once_cell", 718 | "pest", 719 | "sha1", 720 | ] 721 | 722 | [[package]] 723 | name = "proc-macro2" 724 | version = "1.0.43" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" 727 | dependencies = [ 728 | "unicode-ident", 729 | ] 730 | 731 | [[package]] 732 | name = "pwd" 733 | version = "1.4.0" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "72c71c0c79b9701efe4e1e4b563b2016dd4ee789eb99badcb09d61ac4b92e4a2" 736 | dependencies = [ 737 | "libc", 738 | "thiserror", 739 | ] 740 | 741 | [[package]] 742 | name = "quote" 743 | version = "1.0.21" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 746 | dependencies = [ 747 | "proc-macro2", 748 | ] 749 | 750 | [[package]] 751 | name = "redox_syscall" 752 | version = "0.2.16" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 755 | dependencies = [ 756 | "bitflags", 757 | ] 758 | 759 | [[package]] 760 | name = "redox_users" 761 | version = "0.4.3" 762 | source = "registry+https://github.com/rust-lang/crates.io-index" 763 | checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 764 | dependencies = [ 765 | "getrandom", 766 | "redox_syscall", 767 | "thiserror", 768 | ] 769 | 770 | [[package]] 771 | name = "regex" 772 | version = "1.6.0" 773 | source = "registry+https://github.com/rust-lang/crates.io-index" 774 | checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" 775 | dependencies = [ 776 | "aho-corasick", 777 | "memchr", 778 | "regex-syntax", 779 | ] 780 | 781 | [[package]] 782 | name = "regex-syntax" 783 | version = "0.6.27" 784 | source = "registry+https://github.com/rust-lang/crates.io-index" 785 | checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" 786 | 787 | [[package]] 788 | name = "rustc-demangle" 789 | version = "0.1.21" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" 792 | 793 | [[package]] 794 | name = "scopeguard" 795 | version = "1.1.0" 796 | source = "registry+https://github.com/rust-lang/crates.io-index" 797 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 798 | 799 | [[package]] 800 | name = "serde" 801 | version = "1.0.145" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" 804 | dependencies = [ 805 | "serde_derive", 806 | ] 807 | 808 | [[package]] 809 | name = "serde_derive" 810 | version = "1.0.145" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" 813 | dependencies = [ 814 | "proc-macro2", 815 | "quote", 816 | "syn", 817 | ] 818 | 819 | [[package]] 820 | name = "sha1" 821 | version = "0.10.5" 822 | source = "registry+https://github.com/rust-lang/crates.io-index" 823 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" 824 | dependencies = [ 825 | "cfg-if", 826 | "cpufeatures", 827 | "digest", 828 | ] 829 | 830 | [[package]] 831 | name = "signal-hook" 832 | version = "0.3.14" 833 | source = "registry+https://github.com/rust-lang/crates.io-index" 834 | checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" 835 | dependencies = [ 836 | "libc", 837 | "signal-hook-registry", 838 | ] 839 | 840 | [[package]] 841 | name = "signal-hook-mio" 842 | version = "0.2.3" 843 | source = "registry+https://github.com/rust-lang/crates.io-index" 844 | checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" 845 | dependencies = [ 846 | "libc", 847 | "mio", 848 | "signal-hook", 849 | ] 850 | 851 | [[package]] 852 | name = "signal-hook-registry" 853 | version = "1.4.0" 854 | source = "registry+https://github.com/rust-lang/crates.io-index" 855 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 856 | dependencies = [ 857 | "libc", 858 | ] 859 | 860 | [[package]] 861 | name = "smallvec" 862 | version = "1.9.0" 863 | source = "registry+https://github.com/rust-lang/crates.io-index" 864 | checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" 865 | 866 | [[package]] 867 | name = "smawk" 868 | version = "0.3.1" 869 | source = "registry+https://github.com/rust-lang/crates.io-index" 870 | checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" 871 | 872 | [[package]] 873 | name = "supports-color" 874 | version = "1.3.0" 875 | source = "registry+https://github.com/rust-lang/crates.io-index" 876 | checksum = "4872ced36b91d47bae8a214a683fe54e7078875b399dfa251df346c9b547d1f9" 877 | dependencies = [ 878 | "atty", 879 | "is_ci", 880 | ] 881 | 882 | [[package]] 883 | name = "supports-hyperlinks" 884 | version = "1.2.0" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" 887 | dependencies = [ 888 | "atty", 889 | ] 890 | 891 | [[package]] 892 | name = "supports-unicode" 893 | version = "1.0.2" 894 | source = "registry+https://github.com/rust-lang/crates.io-index" 895 | checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" 896 | dependencies = [ 897 | "atty", 898 | ] 899 | 900 | [[package]] 901 | name = "syn" 902 | version = "1.0.100" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" 905 | dependencies = [ 906 | "proc-macro2", 907 | "quote", 908 | "unicode-ident", 909 | ] 910 | 911 | [[package]] 912 | name = "sys-locale" 913 | version = "0.2.1" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "658ee915b6c7b73ec4c1ffcd838506b5c5a4087eadc1ec8f862f1066cf2c8132" 916 | dependencies = [ 917 | "cc", 918 | "cstr_core", 919 | "js-sys", 920 | "libc", 921 | "wasm-bindgen", 922 | "web-sys", 923 | "winapi", 924 | ] 925 | 926 | [[package]] 927 | name = "terminal_size" 928 | version = "0.1.17" 929 | source = "registry+https://github.com/rust-lang/crates.io-index" 930 | checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" 931 | dependencies = [ 932 | "libc", 933 | "winapi", 934 | ] 935 | 936 | [[package]] 937 | name = "textwrap" 938 | version = "0.15.1" 939 | source = "registry+https://github.com/rust-lang/crates.io-index" 940 | checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" 941 | dependencies = [ 942 | "smawk", 943 | "unicode-linebreak", 944 | "unicode-width", 945 | ] 946 | 947 | [[package]] 948 | name = "thiserror" 949 | version = "1.0.35" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85" 952 | dependencies = [ 953 | "thiserror-impl", 954 | ] 955 | 956 | [[package]] 957 | name = "thiserror-impl" 958 | version = "1.0.35" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783" 961 | dependencies = [ 962 | "proc-macro2", 963 | "quote", 964 | "syn", 965 | ] 966 | 967 | [[package]] 968 | name = "time" 969 | version = "0.1.44" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" 972 | dependencies = [ 973 | "libc", 974 | "wasi 0.10.0+wasi-snapshot-preview1", 975 | "winapi", 976 | ] 977 | 978 | [[package]] 979 | name = "typenum" 980 | version = "1.15.0" 981 | source = "registry+https://github.com/rust-lang/crates.io-index" 982 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 983 | 984 | [[package]] 985 | name = "typetag" 986 | version = "0.1.8" 987 | source = "registry+https://github.com/rust-lang/crates.io-index" 988 | checksum = "4080564c5b2241b5bff53ab610082234e0c57b0417f4bd10596f183001505b8a" 989 | dependencies = [ 990 | "erased-serde", 991 | "inventory", 992 | "once_cell", 993 | "serde", 994 | "typetag-impl", 995 | ] 996 | 997 | [[package]] 998 | name = "typetag-impl" 999 | version = "0.1.8" 1000 | source = "registry+https://github.com/rust-lang/crates.io-index" 1001 | checksum = "e60147782cc30833c05fba3bab1d9b5771b2685a2557672ac96fa5d154099c0e" 1002 | dependencies = [ 1003 | "proc-macro2", 1004 | "quote", 1005 | "syn", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "ucd-trie" 1010 | version = "0.1.5" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" 1013 | 1014 | [[package]] 1015 | name = "unicode-ident" 1016 | version = "1.0.4" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" 1019 | 1020 | [[package]] 1021 | name = "unicode-linebreak" 1022 | version = "0.1.3" 1023 | source = "registry+https://github.com/rust-lang/crates.io-index" 1024 | checksum = "ba853b89cad55680dd3cf06f2798cb1ad8d483f0e2dfa14138d7e789ecee5c4e" 1025 | dependencies = [ 1026 | "hashbrown", 1027 | "regex", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "unicode-width" 1032 | version = "0.1.10" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 1035 | 1036 | [[package]] 1037 | name = "utf8-width" 1038 | version = "0.1.6" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" 1041 | 1042 | [[package]] 1043 | name = "version_check" 1044 | version = "0.9.4" 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" 1046 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1047 | 1048 | [[package]] 1049 | name = "wasi" 1050 | version = "0.10.0+wasi-snapshot-preview1" 1051 | source = "registry+https://github.com/rust-lang/crates.io-index" 1052 | checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" 1053 | 1054 | [[package]] 1055 | name = "wasi" 1056 | version = "0.11.0+wasi-snapshot-preview1" 1057 | source = "registry+https://github.com/rust-lang/crates.io-index" 1058 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1059 | 1060 | [[package]] 1061 | name = "wasm-bindgen" 1062 | version = "0.2.83" 1063 | source = "registry+https://github.com/rust-lang/crates.io-index" 1064 | checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" 1065 | dependencies = [ 1066 | "cfg-if", 1067 | "wasm-bindgen-macro", 1068 | ] 1069 | 1070 | [[package]] 1071 | name = "wasm-bindgen-backend" 1072 | version = "0.2.83" 1073 | source = "registry+https://github.com/rust-lang/crates.io-index" 1074 | checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" 1075 | dependencies = [ 1076 | "bumpalo", 1077 | "log", 1078 | "once_cell", 1079 | "proc-macro2", 1080 | "quote", 1081 | "syn", 1082 | "wasm-bindgen-shared", 1083 | ] 1084 | 1085 | [[package]] 1086 | name = "wasm-bindgen-macro" 1087 | version = "0.2.83" 1088 | source = "registry+https://github.com/rust-lang/crates.io-index" 1089 | checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" 1090 | dependencies = [ 1091 | "quote", 1092 | "wasm-bindgen-macro-support", 1093 | ] 1094 | 1095 | [[package]] 1096 | name = "wasm-bindgen-macro-support" 1097 | version = "0.2.83" 1098 | source = "registry+https://github.com/rust-lang/crates.io-index" 1099 | checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" 1100 | dependencies = [ 1101 | "proc-macro2", 1102 | "quote", 1103 | "syn", 1104 | "wasm-bindgen-backend", 1105 | "wasm-bindgen-shared", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "wasm-bindgen-shared" 1110 | version = "0.2.83" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" 1113 | 1114 | [[package]] 1115 | name = "web-sys" 1116 | version = "0.3.60" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" 1119 | dependencies = [ 1120 | "js-sys", 1121 | "wasm-bindgen", 1122 | ] 1123 | 1124 | [[package]] 1125 | name = "winapi" 1126 | version = "0.3.9" 1127 | source = "registry+https://github.com/rust-lang/crates.io-index" 1128 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1129 | dependencies = [ 1130 | "winapi-i686-pc-windows-gnu", 1131 | "winapi-x86_64-pc-windows-gnu", 1132 | ] 1133 | 1134 | [[package]] 1135 | name = "winapi-i686-pc-windows-gnu" 1136 | version = "0.4.0" 1137 | source = "registry+https://github.com/rust-lang/crates.io-index" 1138 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1139 | 1140 | [[package]] 1141 | name = "winapi-x86_64-pc-windows-gnu" 1142 | version = "0.4.0" 1143 | source = "registry+https://github.com/rust-lang/crates.io-index" 1144 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1145 | 1146 | [[package]] 1147 | name = "windows-sys" 1148 | version = "0.36.1" 1149 | source = "registry+https://github.com/rust-lang/crates.io-index" 1150 | checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" 1151 | dependencies = [ 1152 | "windows_aarch64_msvc", 1153 | "windows_i686_gnu", 1154 | "windows_i686_msvc", 1155 | "windows_x86_64_gnu", 1156 | "windows_x86_64_msvc", 1157 | ] 1158 | 1159 | [[package]] 1160 | name = "windows_aarch64_msvc" 1161 | version = "0.36.1" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" 1164 | 1165 | [[package]] 1166 | name = "windows_i686_gnu" 1167 | version = "0.36.1" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" 1170 | 1171 | [[package]] 1172 | name = "windows_i686_msvc" 1173 | version = "0.36.1" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" 1176 | 1177 | [[package]] 1178 | name = "windows_x86_64_gnu" 1179 | version = "0.36.1" 1180 | source = "registry+https://github.com/rust-lang/crates.io-index" 1181 | checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" 1182 | 1183 | [[package]] 1184 | name = "windows_x86_64_msvc" 1185 | version = "0.36.1" 1186 | source = "registry+https://github.com/rust-lang/crates.io-index" 1187 | checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" 1188 | -------------------------------------------------------------------------------- /example.nu: -------------------------------------------------------------------------------- 1 | [[a b]; [1 2] [1 4] [2 6] [2 4]] 2 | | into df 3 | | group-by a 4 | | agg [ 5 | (col b | min | as "b_min") 6 | (col b | max | as "b_max") 7 | (col b | sum | as "b_sum") 8 | ] 9 | 10 | 11 | [[a b]; [1 2] [1 4] [2 6] [2 4]] 12 | | into lazy 13 | | group-by a 14 | | agg [ 15 | (col b | min | as "b_min") 16 | (col b | max | as "b_max") 17 | (col b | sum | as "b_sum") 18 | ] 19 | | collect 20 | 21 | 22 | 23 | 24 | 25 | alias ll = ls -l 26 | 27 | 28 | echo [[status]; [UP] [UP]] | all status == UP 29 | 30 | 31 | echo [2 4 6 8] | all ($it mod 2) == 0 32 | 33 | 34 | [false false false] | into df | all-false 35 | 36 | 37 | let s = ([5 6 2 10] | into df); 38 | let res = ($s > 9); 39 | $res | all-false 40 | 41 | 42 | [true true true] | into df | all-true 43 | 44 | 45 | let s = ([5 6 2 8] | into df); 46 | let res = ($s > 9); 47 | $res | all-true 48 | 49 | 50 | (field a) > 1 | and ((field a) < 10) | into nu 51 | 52 | 53 | open db.sqlite 54 | | from table table_1 55 | | select a 56 | | where ((field a) > 1) 57 | | and ((field b) == 1) 58 | | describe 59 | 60 | 61 | open db.sqlite 62 | | from table table_1 63 | | select a 64 | | where ((field a) > 1 | and ((field a) < 10)) 65 | | and ((field b) == 1) 66 | | describe 67 | 68 | 69 | ansi green 70 | 71 | 72 | ansi reset 73 | 74 | 75 | echo [(ansi rb) Hello " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str collect 76 | 77 | 78 | echo [(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str collect 79 | 80 | 81 | $"(ansi -e { fg: '#0000ff' bg: '#ff0000' attr: b })Hello Nu World(ansi reset)" 82 | 83 | 84 | echo 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff --fgend 0xe81cff 85 | 86 | 87 | echo 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff --fgend 0xe81cff --bgstart 0xe81cff --bgend 0x40c9ff 88 | 89 | 90 | echo 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart 0x40c9ff 91 | 92 | 93 | echo 'Hello, Nushell! This is a gradient.' | ansi gradient --fgend 0xe81cff 94 | 95 | 96 | echo [ (ansi green) (ansi cursor_on) "hello" ] | str collect | ansi strip 97 | 98 | 99 | echo [[status]; [UP] [DOWN] [UP]] | any status == DOWN 100 | 101 | 102 | echo [2 4 1 6 8] | any ($it mod 2) == 1 103 | 104 | 105 | let a = ([[a b]; [1 2] [3 4]] | into df); 106 | $a | append $a 107 | 108 | 109 | let a = ([[a b]; [1 2] [3 4]] | into df); 110 | $a | append $a --col 111 | 112 | 113 | [0,1,2,3] | append 4 114 | 115 | 116 | [0,1] | append [2,3,4] 117 | 118 | 119 | [0,1] | append [2,nu,4,shell] 120 | 121 | 122 | [1 3 2] | into df | arg-max 123 | 124 | 125 | [1 3 2] | into df | arg-min 126 | 127 | 128 | [1 2 2 3 3] | into df | arg-sort 129 | 130 | 131 | [1 2 2 3 3] | into df | arg-sort -r 132 | 133 | 134 | [false true false] | into df | arg-true 135 | 136 | 137 | [1 2 2 3 3] | into df | arg-unique 138 | 139 | 140 | let df = ([[a b]; [one 1] [two 2] [three 3]] | into df); 141 | $df | select (arg-where ((col b) >= 2) | as b_arg) 142 | 143 | 144 | col a | as new_a | into nu 145 | 146 | 147 | field name_a | as new_a | into nu 148 | 149 | 150 | open db.sqlite 151 | | from table table_1 152 | | select a 153 | | as t1 154 | | describe 155 | 156 | 157 | open db.sqlite 158 | | from table ( 159 | open db.sqlite 160 | | from table table_a 161 | | select a b 162 | ) 163 | | select a 164 | | as t1 165 | | describe 166 | 167 | 168 | ["2021-12-30" "2021-12-31"] | into df | as-datetime "%Y-%m-%d" 169 | 170 | 171 | ["2021-12-30 00:00:00" "2021-12-31 00:00:00"] | into df | as-datetime "%Y-%m-%d %H:%M:%S" 172 | 173 | 174 | ast 'hello' 175 | 176 | 177 | ast 'ls | where name =~ README' 178 | 179 | 180 | ast 'for x in 1..10 { echo $x ' 181 | 182 | 183 | benchmark { sleep 500ms } 184 | 185 | 186 | 2 | bits and 2 187 | 188 | 189 | [4 3 2] | bits and 2 190 | 191 | 192 | [4 3 2] | bits not 193 | 194 | 195 | [4 3 2] | bits not -n 2 196 | 197 | 198 | [4 3 2] | bits not -s 199 | 200 | 201 | 2 | bits or 6 202 | 203 | 204 | [8 3 2] | bits or 2 205 | 206 | 207 | 17 | bits rol 2 208 | 209 | 210 | [5 3 2] | bits rol 2 211 | 212 | 213 | 17 | bits ror 60 214 | 215 | 216 | [15 33 92] | bits ror 2 -n 1 217 | 218 | 219 | 2 | bits shl 7 220 | 221 | 222 | 2 | bits shl 7 -n 1 223 | 224 | 225 | 0x7F | bits shl 1 -s 226 | 227 | 228 | [5 3 2] | bits shl 2 229 | 230 | 231 | 8 | bits shr 2 232 | 233 | 234 | [15 35 2] | bits shr 2 235 | 236 | 237 | 2 | bits xor 2 238 | 239 | 240 | [8 3 2] | bits xor 2 241 | 242 | 243 | build-string a b c 244 | 245 | 246 | build-string $"(1 + 2)" = one ' ' plus ' ' two 247 | 248 | 249 | 0x[1F FF AA AA] | bytes add 0x[AA] 250 | 251 | 252 | 0x[1F FF AA AA] | bytes add 0x[AA BB] -i 1 253 | 254 | 255 | 0x[FF AA AA] | bytes add 0x[11] -e 256 | 257 | 258 | 0x[FF AA BB] | bytes add 0x[11 22 33] -e -i 1 259 | 260 | 261 | 0x[33 44 55 10 01 13] | bytes at [3 4] 262 | 263 | 264 | 0x[33 44 55 10 01 13] | bytes at '3,4' 265 | 266 | 267 | 0x[33 44 55 10 01 13] | bytes at ',-3' 268 | 269 | 270 | 0x[33 44 55 10 01 13] | bytes at '3,' 271 | 272 | 273 | 0x[33 44 55 10 01 13] | bytes at ',4' 274 | 275 | 276 | [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes at "1," ColB ColC 277 | 278 | 279 | bytes build 0x[01 02] 0x[03] 0x[04] 280 | 281 | 282 | [0x[11] 0x[13 15]] | bytes collect 283 | 284 | 285 | [0x[11] 0x[33] 0x[44]] | bytes collect 0x[01] 286 | 287 | 288 | 0x[1F FF AA AA] | bytes ends-with 0x[AA] 289 | 290 | 291 | 0x[1F FF AA AA] | bytes ends-with 0x[FF AA AA] 292 | 293 | 294 | 0x[1F FF AA AA] | bytes ends-with 0x[11] 295 | 296 | 297 | 0x[33 44 55 10 01 13 44 55] | bytes index-of 0x[44 55] 298 | 299 | 300 | 0x[33 44 55 10 01 13 44 55] | bytes index-of -e 0x[44 55] 301 | 302 | 303 | 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a 0x[33 44] 304 | 305 | 306 | 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a -e 0x[33 44] 307 | 308 | 309 | [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes index-of 0x[11] ColA ColC 310 | 311 | 312 | 0x[1F FF AA AB] | bytes length 313 | 314 | 315 | [0x[1F FF AA AB] 0x[1F]] | bytes length 316 | 317 | 318 | 0x[10 AA FF AA FF] | bytes remove 0x[10 AA] 319 | 320 | 321 | 0x[10 AA 10 BB 10] | bytes remove -a 0x[10] 322 | 323 | 324 | 0x[10 AA 10 BB CC AA 10] | bytes remove -e 0x[10] 325 | 326 | 327 | [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes remove 0x[11] ColA ColC 328 | 329 | 330 | 0x[10 AA FF AA FF] | bytes replace 0x[10 AA] 0x[FF] 331 | 332 | 333 | 0x[10 AA 10 BB 10] | bytes replace -a 0x[10] 0x[A0] 334 | 335 | 336 | [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes replace -a 0x[11] 0x[13] ColA ColC 337 | 338 | 339 | 0x[1F FF AA AA] | bytes reverse 340 | 341 | 342 | 0x[FF AA AA] | bytes reverse 343 | 344 | 345 | 0x[1F FF AA AA] | bytes starts-with 0x[1F FF AA] 346 | 347 | 348 | 0x[1F FF AA AA] | bytes starts-with 0x[1F] 349 | 350 | 351 | 0x[1F FF AA AA] | bytes starts-with 0x[11] 352 | 353 | 354 | [[a b]; [6 2] [4 2] [2 2]] | into df | reverse | cache 355 | 356 | 357 | cal 358 | 359 | 360 | cal --full-year 2012 361 | 362 | 363 | cal --week-start monday 364 | 365 | 366 | cd ~ 367 | 368 | 369 | cd d/s/9 370 | 371 | 372 | cd - 373 | 374 | 375 | char newline 376 | 377 | 378 | echo [(char prompt) (char newline) (char hamburger)] | str collect 379 | 380 | 381 | char -u "1f378" 382 | 383 | 384 | char -i (0x60 + 1) (0x60 + 2) 385 | 386 | 387 | char -u "1F468 200D 1F466 200D 1F466" 388 | 389 | 390 | clear 391 | 392 | 393 | col a | into nu 394 | 395 | 396 | echo 1 2 3 | collect { |x| echo $x.1 } 397 | 398 | 399 | open foo.db | from table table_1 db | select a | collect 400 | 401 | 402 | [[a b]; [1 2] [3 4]] | into lazy | collect 403 | 404 | 405 | [[a b]; [1 2] [3 4]] | into df | columns 406 | 407 | 408 | [[name,age,grade]; [bill,20,a]] | columns 409 | 410 | 411 | [[name,age,grade]; [bill,20,a]] | columns | first 412 | 413 | 414 | [[name,age,grade]; [bill,20,a]] | columns | select 1 415 | 416 | 417 | echo [["Hello" "World"]; [$nothing 3]]| compact Hello 418 | 419 | 420 | echo [["Hello" "World"]; [$nothing 3]]| compact World 421 | 422 | 423 | echo [1, $nothing, 2] | compact 424 | 425 | 426 | ^external arg1 | complete 427 | 428 | 429 | let df = ([[a b c]; [one two 1] [three four 2]] | into df); 430 | $df | with-column ((concat-str "-" [(col a) (col b) ((col c) * 2)]) | as concat) 431 | 432 | 433 | let other = ([za xs cd] | into df); 434 | [abc abc abc] | into df | concatenate $other 435 | 436 | 437 | config env 438 | 439 | 440 | config nu 441 | 442 | 443 | config reset 444 | 445 | 446 | [abc acb acb] | into df | contains ab 447 | 448 | 449 | 450 | 451 | 452 | let s = ([1 1 0 0 3 3 4] | into df); 453 | ($s / $s) | count-null 454 | 455 | 456 | cp myfile dir_b 457 | 458 | 459 | cp -r dir_a dir_b 460 | 461 | 462 | cp -r -v dir_a dir_b 463 | 464 | 465 | cp *.txt dir_a 466 | 467 | 468 | [1 2 3 4 5] | into df | cumulative sum 469 | 470 | 471 | "2021-10-22 20:00:12 +01:00" | date format 472 | 473 | 474 | date format '%Y-%m-%d' 475 | 476 | 477 | date format "%Y-%m-%d %H:%M:%S" 478 | 479 | 480 | "2021-10-22 20:00:12 +01:00" | date format "%Y-%m-%d" 481 | 482 | 483 | date humanize 484 | 485 | 486 | "2021-10-22 20:00:12 +01:00" | date humanize 487 | 488 | 489 | date list-timezone | where timezone =~ Shanghai 490 | 491 | 492 | date now | date format "%Y-%m-%d %H:%M:%S" 493 | 494 | 495 | (date now) - d"2019-05-01" 496 | 497 | 498 | (date now) - d"2019-05-01T04:12:05.20+08:00" 499 | 500 | 501 | date now | debug 502 | 503 | 504 | date to-table 505 | 506 | 507 | date now | date to-record 508 | 509 | 510 | '2020-04-12 22:10:57 +0200' | date to-record 511 | 512 | 513 | date to-table 514 | 515 | 516 | date now | date to-table 517 | 518 | 519 | '2020-04-12 22:10:57 +0200' | date to-table 520 | 521 | 522 | date now | date to-timezone +0500 523 | 524 | 525 | date now | date to-timezone local 526 | 527 | 528 | date now | date to-timezone US/Hawaii 529 | 530 | 531 | "2020-10-10 10:00:00 +02:00" | date to-timezone "+0500" 532 | 533 | 534 | 'hello' | debug 535 | 536 | 537 | echo [[version patch]; ["0.1.0" false] ["0.1.1" true] ["0.2.0" false]] | debug 538 | 539 | 540 | ^cat myfile.q | decode utf-8 541 | 542 | 543 | 0x[00 53 00 6F 00 6D 00 65 00 20 00 44 00 61 00 74 00 61] | decode utf-16be 544 | 545 | 546 | echo 'U29tZSBEYXRh' | decode base64 547 | 548 | 549 | echo 'U29tZSBEYXRh' | decode base64 --binary 550 | 551 | 552 | def say-hi [] { echo 'hi' }; say-hi 553 | 554 | 555 | def say-sth [sth: string] { echo $sth }; say-sth hi 556 | 557 | 558 | def-env foo [] { let-env BAR = "BAZ" }; foo; $env.BAR 559 | 560 | 561 | ls -la | default 'nothing' target 562 | 563 | 564 | $env | get -i MY_ENV | default 'abc' 565 | 566 | 567 | [1, 2, $nothing, 4] | default 3 568 | 569 | 570 | 'hello' | describe 571 | 572 | 573 | [[a b]; [1 1] [1 1]] | into df | describe 574 | 575 | 576 | open foo.db | from table table_1 | select col_1 | describe 577 | 578 | 579 | echo 'a b c' | detect columns -n 580 | 581 | 582 | echo $'c1 c2 c3(char nl)a b c' | detect columns 583 | 584 | 585 | [true false true] | into df | df-not 586 | 587 | 588 | do { echo hello } 589 | 590 | 591 | do -i { thisisnotarealcommand } 592 | 593 | 594 | do {|x| 100 + $x } 50 595 | 596 | 597 | [0,1,2,3] | drop 598 | 599 | 600 | [0,1,2,3] | drop 0 601 | 602 | 603 | [0,1,2,3] | drop 2 604 | 605 | 606 | [[a b]; [1 2] [3 4]] | into df | drop a 607 | 608 | 609 | echo [[lib, extension]; [nu-lib, rs] [nu-core, rb]] | drop column 610 | 611 | 612 | [sam,sarah,2,3,4,5] | drop nth 0 1 2 613 | 614 | 615 | [0,1,2,3,4,5] | drop nth 0 1 2 616 | 617 | 618 | [0,1,2,3,4,5] | drop nth 0 2 4 619 | 620 | 621 | [0,1,2,3,4,5] | drop nth 2 0 4 622 | 623 | 624 | echo [first second third fourth fifth] | drop nth (1..3) 625 | 626 | 627 | [0,1,2,3,4,5] | drop nth 1.. 628 | 629 | 630 | [0,1,2,3,4,5] | drop nth 3.. 631 | 632 | 633 | [[a b]; [1 2] [3 4] [1 2]] | into df | drop-duplicates 634 | 635 | 636 | let df = ([[a b]; [1 2] [3 0] [1 2]] | into df); 637 | let res = ($df.b / $df.b); 638 | let a = ($df | with-column $res --name res); 639 | $a | drop-nulls 640 | 641 | 642 | let s = ([1 2 0 0 3 4] | into df); 643 | ($s / $s) | drop-nulls 644 | 645 | 646 | [[a b]; [1 2] [3 4]] | into df | dtypes 647 | 648 | 649 | du 650 | 651 | 652 | [[a b]; [1 2] [3 4]] | into df | dummies 653 | 654 | 655 | [1 2 2 3 3] | into df | dummies 656 | 657 | 658 | [1 2 3] | each { |it| 2 * $it } 659 | 660 | 661 | [1 2 3] | each { |it| if $it == 2 { echo "found 2!"} } 662 | 663 | 664 | [1 2 3] | each -n { |it| if $it.item == 2 { echo $"found 2 at ($it.index)!"} } 665 | 666 | 667 | [1 2 3] | each --keep-empty { |it| if $it == 2 { echo "found 2!"} } 668 | 669 | 670 | [1 2 3] | each while { |it| if $it < 3 {$it} else {$nothing} } 671 | 672 | 673 | [1 2 3] | each while -n { |it| if $it.item < 2 { $"value ($it.item) at ($it.index)!"} else { $nothing } } 674 | 675 | 676 | echo 'hello' 677 | 678 | 679 | echo $nu 680 | 681 | 682 | echo "負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis 683 | 684 | 685 | echo 'Some Data' | encode base64 686 | 687 | 688 | echo 'Some Data' | encode base64 --character-set binhex 689 | 690 | 691 | enter ../dir-foo 692 | 693 | 694 | env | where name == PATH 695 | 696 | 697 | env | any name == MY_ENV_ABC 698 | 699 | 700 | 'PATH' in (env).name 701 | 702 | 703 | def foo [x] { 704 | let span = (metadata $x).span; 705 | error make {msg: "this is fishy", label: {text: "fish right here", start: $span.start, end: $span.end } } 706 | } 707 | 708 | 709 | def foo [x] { 710 | error make {msg: "this is fishy"} 711 | } 712 | 713 | 714 | [1 2 3 4 5] | every 2 715 | 716 | 717 | [1 2 3 4 5] | every 2 --skip 718 | 719 | 720 | exec ps aux 721 | 722 | 723 | exec nautilus 724 | 725 | 726 | exit 727 | 728 | 729 | exit --now 730 | 731 | 732 | 733 | 734 | 735 | module utils { export def my-command [] { "hello" } }; use utils my-command; my-command 736 | 737 | 738 | export alias ll = ls -l 739 | 740 | 741 | module spam { export def foo [] { "foo" } }; use spam foo; foo 742 | 743 | 744 | module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR 745 | 746 | 747 | module foo { export env FOO_ENV { "BAZ" } }; use foo FOO_ENV; $env.FOO_ENV 748 | 749 | 750 | export extern echo [text: string] 751 | 752 | 753 | module spam { export def foo [] { "foo" } } 754 | module eggs { export use spam foo } 755 | use eggs foo 756 | foo 757 | 758 | 759 | 760 | export-env { let-env SPAM = 'eggs' }; $env.SPAM 761 | 762 | 763 | ((col a) > 2) | expr-not 764 | 765 | 766 | extern echo [text: string] 767 | 768 | 769 | [[a b]; [6 2] [4 2] [2 2]] | into df | fetch 2 770 | 771 | 772 | fetch url.com 773 | 774 | 775 | fetch -u myuser -p mypass url.com 776 | 777 | 778 | fetch -H [my-header-key my-header-value] url.com 779 | 780 | 781 | field name_1 | into nu 782 | 783 | 784 | 785 | 786 | 787 | [1 2 2 3 3] | into df | shift 2 | fill-null 0 788 | 789 | 790 | [[a b]; [6 2] [4 2] [2 2]] | into df | filter ((col a) >= 4) 791 | 792 | 793 | let mask = ([true false] | into df); 794 | [[a b]; [1 2] [3 4]] | into df | filter-with $mask 795 | 796 | 797 | [[a b]; [1 2] [3 4]] | into df | filter-with ((col a) > 1) 798 | 799 | 800 | ls | find toml md sh 801 | 802 | 803 | echo Cargo.toml | find toml 804 | 805 | 806 | [1 5 3kb 4 3Mb] | find 5 3kb 807 | 808 | 809 | [moe larry curly] | find l 810 | 811 | 812 | [2 4 3 6 5 8] | find --predicate { |it| ($it mod 2) == 1 } 813 | 814 | 815 | [[version patch]; ["0.1.0" false] ["0.1.1" true] ["0.2.0" false]] | find -p { |it| $it.patch } 816 | 817 | 818 | [abc bde arc abf] | find --regex "ab" 819 | 820 | 821 | [aBc bde Arc abf] | find --regex "ab" -i 822 | 823 | 824 | [[version name]; ["0.1.0" nushell] ["0.1.1" fish] ["0.2.0" zsh]] | find -r "nu" 825 | 826 | 827 | [1 2 3] | first 828 | 829 | 830 | [1 2 3] | first 2 831 | 832 | 833 | 0x[01 23 45] | first 2 834 | 835 | 836 | col a | first 837 | 838 | 839 | [[a b]; [1 2] [3 4]] | into df | first 840 | 841 | 842 | [[a b]; [1 2] [3 4]] | into df | first 2 843 | 844 | 845 | [[N, u, s, h, e, l, l]] | flatten 846 | 847 | 848 | [[N, u, s, h, e, l, l]] | flatten | first 849 | 850 | 851 | [[origin, people]; [Ecuador, ([[name, meal]; ['Andres', 'arepa']])]] | flatten --all | get meal 852 | 853 | 854 | [[origin, crate, versions]; [World, ([[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions --all | last | get versions 855 | 856 | 857 | { a: b, d: [ 1 2 3 4 ], e: [ 4 3 ] } | flatten d --all 858 | 859 | 860 | 861 | 862 | 863 | 42 | fmt 864 | 865 | 866 | fn count name_1 | into nu 867 | 868 | 869 | open db.sqlite 870 | | from table table_a 871 | | select (fn lead col_a) 872 | | describe 873 | 874 | 875 | for x in [1 2 3] { $x * $x } 876 | 877 | 878 | for $x in 1..3 { $x } 879 | 880 | 881 | for $it in ['bob' 'fred'] --numbered { $"($it.index) is ($it.item)" } 882 | 883 | 884 | ls | format '{name}: {size}' 885 | 886 | 887 | echo [[col1, col2]; [v1, v2] [v3, v4]] | format '{col2}' 888 | 889 | 890 | ls | format filesize size KB 891 | 892 | 893 | du | format filesize apparent B 894 | 895 | 896 | open data.txt | from csv 897 | 898 | 899 | open data.txt | from csv --noheaders 900 | 901 | 902 | open data.txt | from csv -n 903 | 904 | 905 | open data.txt | from csv --separator ';' 906 | 907 | 908 | open data.txt | from csv --trim all 909 | 910 | 911 | open data.txt | from csv --trim headers 912 | 913 | 914 | open data.txt | from csv --trim fields 915 | 916 | 917 | 'From: test@email.com 918 | Subject: Welcome 919 | To: someone@somewhere.com 920 | 921 | Test' | from eml 922 | 923 | 924 | 'From: test@email.com 925 | Subject: Welcome 926 | To: someone@somewhere.com 927 | 928 | Test' | from eml -b 1 929 | 930 | 931 | 'BEGIN:VCALENDAR 932 | END:VCALENDAR' | from ics 933 | 934 | 935 | '[foo] 936 | a=1 937 | b=2' | from ini 938 | 939 | 940 | '{ "a": 1 }' | from json 941 | 942 | 943 | '{ "a": 1, "b": [1, 2] }' | from json 944 | 945 | 946 | '{ a:1 }' | from nuon 947 | 948 | 949 | '{ a:1, b: [1, 2] }' | from nuon 950 | 951 | 952 | open --raw test.ods | from ods 953 | 954 | 955 | open --raw test.ods | from ods -s [Spreadsheet1] 956 | 957 | 958 | 'FOO BAR 959 | 1 2' | from ssv 960 | 961 | 962 | 'FOO BAR 963 | 1 2' | from ssv -n 964 | 965 | 966 | open db.sqlite | from table table_a | describe 967 | 968 | 969 | 'a = 1' | from toml 970 | 971 | 972 | 'a = 1 973 | b = [1, 2]' | from toml 974 | 975 | 976 | echo $'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv 977 | 978 | 979 | echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n 980 | 981 | 982 | echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all 983 | 984 | 985 | echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers 986 | 987 | 988 | echo $'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields 989 | 990 | 991 | 'bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter' | from url 992 | 993 | 994 | 'BEGIN:VCARD 995 | N:Foo 996 | FN:Bar 997 | EMAIL:foo@bar.com 998 | END:VCARD' | from vcf 999 | 1000 | 1001 | open --raw test.xlsx | from xlsx 1002 | 1003 | 1004 | open --raw test.xlsx | from xlsx -s [Spreadsheet1] 1005 | 1006 | 1007 | ' 1008 | 1009 | Event 1010 | ' | from xml 1011 | 1012 | 1013 | 'a: 1' | from yaml 1014 | 1015 | 1016 | '[ a: 1, b: [1, 2] ]' | from yaml 1017 | 1018 | 1019 | 'a: 1' | from yaml 1020 | 1021 | 1022 | '[ a: 1, b: [1, 2] ]' | from yaml 1023 | 1024 | 1025 | g 1026 | 1027 | 1028 | mkdir foo bar; enter foo; enter ../bar; g 1 1029 | 1030 | 1031 | shells; g 2 1032 | 1033 | 1034 | mkdir foo bar; enter foo; enter ../bar; g - 1035 | 1036 | 1037 | [[a b]; [1 2] [3 4]] | into df | get a 1038 | 1039 | 1040 | ls | get name 1041 | 1042 | 1043 | ls | get name.2 1044 | 1045 | 1046 | # ls | get 2.name 1047 | 1048 | 1049 | sys | get cpu 1050 | 1051 | 1052 | $env | get paTH 1053 | 1054 | 1055 | $env | get -s Path 1056 | 1057 | 1058 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1059 | let df = ([$dt $dt] | into df); 1060 | $df | get-day 1061 | 1062 | 1063 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1064 | let df = ([$dt $dt] | into df); 1065 | $df | get-hour 1066 | 1067 | 1068 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1069 | let df = ([$dt $dt] | into df); 1070 | $df | get-minute 1071 | 1072 | 1073 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1074 | let df = ([$dt $dt] | into df); 1075 | $df | get-month 1076 | 1077 | 1078 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1079 | let df = ([$dt $dt] | into df); 1080 | $df | get-nanosecond 1081 | 1082 | 1083 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1084 | let df = ([$dt $dt] | into df); 1085 | $df | get-ordinal 1086 | 1087 | 1088 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1089 | let df = ([$dt $dt] | into df); 1090 | $df | get-second 1091 | 1092 | 1093 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1094 | let df = ([$dt $dt] | into df); 1095 | $df | get-week 1096 | 1097 | 1098 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1099 | let df = ([$dt $dt] | into df); 1100 | $df | get-weekday 1101 | 1102 | 1103 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 1104 | let df = ([$dt $dt] | into df); 1105 | $df | get-year 1106 | 1107 | 1108 | glob *.rs 1109 | 1110 | 1111 | glob **/*.{rs,toml} --depth 2 1112 | 1113 | 1114 | glob "[Cc]*" 1115 | 1116 | 1117 | glob "{a?c,x?z}" 1118 | 1119 | 1120 | glob "(?i)c*" 1121 | 1122 | 1123 | glob "[!cCbMs]*" 1124 | 1125 | 1126 | glob 1127 | 1128 | 1129 | glob <[a-d]:1,10> 1130 | 1131 | 1132 | [1 2 3 a b c] | grid 1133 | 1134 | 1135 | [1 2 3 a b c] | wrap name | grid 1136 | 1137 | 1138 | {name: 'foo', b: 1, c: 2} | grid 1139 | 1140 | 1141 | [{name: 'A', v: 1} {name: 'B', v: 2} {name: 'C', v: 3}] | grid 1142 | 1143 | 1144 | [[name patch]; ["0.1.0" false] ["0.1.1" true] ["0.2.0" false]] | grid 1145 | 1146 | 1147 | echo [1 2 3 4] | group 2 1148 | 1149 | 1150 | ls | group-by type 1151 | 1152 | 1153 | echo ['1' '3' '1' '3' '2' '1' '1'] | group-by 1154 | 1155 | 1156 | open db.sqlite 1157 | | from table table_a 1158 | | select (fn max a) 1159 | | group-by a 1160 | | describe 1161 | 1162 | 1163 | open db.sqlite 1164 | | from table table_a 1165 | | select (fn count *) 1166 | | group-by a 1167 | | describe 1168 | 1169 | 1170 | [[a b]; [1 2] [1 4] [2 6] [2 4]] 1171 | | into df 1172 | | group-by a 1173 | | agg [ 1174 | (col b | min | as "b_min") 1175 | (col b | max | as "b_max") 1176 | (col b | sum | as "b_sum") 1177 | ] 1178 | 1179 | 1180 | [[a b]; [1 2] [1 4] [2 6] [2 4]] 1181 | | into lazy 1182 | | group-by a 1183 | | agg [ 1184 | (col b | min | as "b_min") 1185 | (col b | max | as "b_max") 1186 | (col b | sum | as "b_sum") 1187 | ] 1188 | | collect 1189 | 1190 | 1191 | echo 'abcdefghijklmnopqrstuvwxyz' | hash md5 1192 | 1193 | 1194 | echo 'abcdefghijklmnopqrstuvwxyz' | hash md5 --binary 1195 | 1196 | 1197 | open ./nu_0_24_1_windows.zip | hash md5 1198 | 1199 | 1200 | echo 'abcdefghijklmnopqrstuvwxyz' | hash sha256 1201 | 1202 | 1203 | echo 'abcdefghijklmnopqrstuvwxyz' | hash sha256 --binary 1204 | 1205 | 1206 | open ./nu_0_24_1_windows.zip | hash sha256 1207 | 1208 | 1209 | "a b c|1 2 3" | split row "|" | split column " " | headers 1210 | 1211 | 1212 | "a b c|1 2 3|1 2 3 4" | split row "|" | split column " " | headers 1213 | 1214 | 1215 | help commands 1216 | 1217 | 1218 | help match 1219 | 1220 | 1221 | help str lpad 1222 | 1223 | 1224 | help --find char 1225 | 1226 | 1227 | alias lll = ls -l; hide lll 1228 | 1229 | 1230 | def say-hi [] { echo 'Hi!' }; hide say-hi 1231 | 1232 | 1233 | let-env HZ_ENV_ABC = 1; hide HZ_ENV_ABC; 'HZ_ENV_ABC' in (env).name 1234 | 1235 | 1236 | let-env HZ_ENV_ABC = 1; hide-env HZ_ENV_ABC; 'HZ_ENV_ABC' in (env).name 1237 | 1238 | 1239 | ls | histogram type 1240 | 1241 | 1242 | ls | histogram type freq 1243 | 1244 | 1245 | echo [1 2 3 1 1 1 2 2 1 1] | histogram 1246 | 1247 | 1248 | echo [1 2 3 1 1 1 2 2 1 1] | histogram --percentage-type relative 1249 | 1250 | 1251 | history | length 1252 | 1253 | 1254 | history | last 5 1255 | 1256 | 1257 | history | wrap cmd | where cmd =~ cargo 1258 | 1259 | 1260 | if 2 < 3 { 'yes!' } 1261 | 1262 | 1263 | if 5 < 3 { 'yes!' } else { 'no!' } 1264 | 1265 | 1266 | if 5 < 3 { 'yes!' } else if 4 < 5 { 'no!' } else { 'okay!' } 1267 | 1268 | 1269 | echo done | ignore 1270 | 1271 | 1272 | let user-input = (input) 1273 | 1274 | 1275 | echo {'name': 'nu', 'stars': 5} | insert alias 'Nushell' 1276 | 1277 | 1278 | 'This is a string that is exactly 52 characters long.' | into binary 1279 | 1280 | 1281 | 1 | into binary 1282 | 1283 | 1284 | true | into binary 1285 | 1286 | 1287 | ls | where name == LICENSE | get size | into binary 1288 | 1289 | 1290 | ls | where name == LICENSE | get name | path expand | into binary 1291 | 1292 | 1293 | 1.234 | into binary 1294 | 1295 | 1296 | echo [[value]; ['false'] ['1'] [0] [1.0] [true]] | into bool value 1297 | 1298 | 1299 | true | into bool 1300 | 1301 | 1302 | 1 | into bool 1303 | 1304 | 1305 | '0.0' | into bool 1306 | 1307 | 1308 | 'true' | into bool 1309 | 1310 | 1311 | '27.02.2021 1:55 pm +0000' | into datetime 1312 | 1313 | 1314 | '2021-02-27T13:55:40+00:00' | into datetime 1315 | 1316 | 1317 | '20210227_135540+0000' | into datetime -f '%Y%m%d_%H%M%S%z' 1318 | 1319 | 1320 | 1614434140 | into datetime 1321 | 1322 | 1323 | 1614434140 | into datetime -o +9 1324 | 1325 | 1326 | 1656165681720 | into datetime 1327 | 1328 | 1329 | open db.sqlite | into db 1330 | 1331 | 1332 | [[num]; ['5.01']] | into decimal num 1333 | 1334 | 1335 | '1.345' | into decimal 1336 | 1337 | 1338 | '-5.9' | into decimal 1339 | 1340 | 1341 | true | into decimal 1342 | 1343 | 1344 | [[a b];[1 2] [3 4]] | into df 1345 | 1346 | 1347 | [[1 2 a] [3 4 b] [5 6 c]] | into df 1348 | 1349 | 1350 | [a b c] | into df 1351 | 1352 | 1353 | [true true false] | into df 1354 | 1355 | 1356 | echo [[value]; ['1sec'] ['2min'] ['3hr'] ['4day'] ['5wk']] | into duration value 1357 | 1358 | 1359 | '7min' | into duration 1360 | 1361 | 1362 | '7min' | into duration --convert sec 1363 | 1364 | 1365 | [[bytes]; ['5'] [3.2] [4] [2kb]] | into filesize bytes 1366 | 1367 | 1368 | '2' | into filesize 1369 | 1370 | 1371 | 8.3 | into filesize 1372 | 1373 | 1374 | 5 | into filesize 1375 | 1376 | 1377 | 4KB | into filesize 1378 | 1379 | 1380 | echo [[num]; ['-5'] [4] [1.5]] | into int num 1381 | 1382 | 1383 | '2' | into int 1384 | 1385 | 1386 | 5.9 | into int 1387 | 1388 | 1389 | '5.9' | into int 1390 | 1391 | 1392 | 4KB | into int 1393 | 1394 | 1395 | [false, true] | into int 1396 | 1397 | 1398 | d"2022-02-02" | into int 1399 | 1400 | 1401 | '1101' | into int -r 2 1402 | 1403 | 1404 | 'FF' | into int -r 16 1405 | 1406 | 1407 | '0o10132' | into int 1408 | 1409 | 1410 | '0010132' | into int 1411 | 1412 | 1413 | '0010132' | into int -r 8 1414 | 1415 | 1416 | [[a b];[1 2] [3 4]] | into lazy 1417 | 1418 | 1419 | col a | into nu 1420 | 1421 | 1422 | [[a b]; [1 2] [3 4]] | into df | into nu 1423 | 1424 | 1425 | [[a b]; [1 2] [5 6] [3 4]] | into df | into nu -t -n 1 1426 | 1427 | 1428 | field name_1 | into nu 1429 | 1430 | 1431 | ls | into sqlite my_ls.db 1432 | 1433 | 1434 | ls | into sqlite my_ls.db -t my_table 1435 | 1436 | 1437 | [[name]; [-----] [someone] ["====="] [somename] ['(((((']] | into sqlite filename.db 1438 | 1439 | 1440 | [one 2 5.2 six true 100mib 25sec] | into sqlite variety.db 1441 | 1442 | 1443 | 5 | into string -d 3 1444 | 1445 | 1446 | 1.7 | into string -d 0 1447 | 1448 | 1449 | 1.7 | into string -d 1 1450 | 1451 | 1452 | 1.734 | into string -d 2 1453 | 1454 | 1455 | 1.734 | into string -d -2 1456 | 1457 | 1458 | 4.3 | into string 1459 | 1460 | 1461 | '1234' | into string 1462 | 1463 | 1464 | true | into string 1465 | 1466 | 1467 | date now | into string 1468 | 1469 | 1470 | ls Cargo.toml | get name | into string 1471 | 1472 | 1473 | ls Cargo.toml | get size | into string 1474 | 1475 | 1476 | if is-admin { echo "iamroot" } else { echo "iamnotroot" } 1477 | 1478 | 1479 | [5 6 6 6 8 8 8] | into df | is-duplicated 1480 | 1481 | 1482 | [[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | into df | is-duplicated 1483 | 1484 | 1485 | '' | is-empty 1486 | 1487 | 1488 | [] | is-empty 1489 | 1490 | 1491 | [[meal size]; [arepa small] [taco '']] | is-empty meal size 1492 | 1493 | 1494 | let df = ([[a b]; [one 1] [two 2] [three 3]] | into df); 1495 | $df | with-column (col a | is-in [one two] | as a_in) 1496 | 1497 | 1498 | let other = ([1 3 6] | into df); 1499 | [5 6 6 6 8 8 8] | into df | is-in $other 1500 | 1501 | 1502 | let s = ([5 6 0 8] | into df); 1503 | let res = ($s / $s); 1504 | $res | is-not-null 1505 | 1506 | 1507 | col a | is-not-null 1508 | 1509 | 1510 | col a | is-null 1511 | 1512 | 1513 | let s = ([5 6 0 8] | into df); 1514 | let res = ($s / $s); 1515 | $res | is-null 1516 | 1517 | 1518 | [5 6 6 6 8 8 8] | into df | is-unique 1519 | 1520 | 1521 | [[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | into df | is-unique 1522 | 1523 | 1524 | let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | into lazy); 1525 | let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | into lazy); 1526 | $df_a | join $df_b a foo | collect 1527 | 1528 | 1529 | let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | into df); 1530 | let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | into lazy); 1531 | $df_a | join $df_b a foo 1532 | 1533 | 1534 | open db.sqlite 1535 | | from table table_1 --as t1 1536 | | join table_2 col_b --as t2 1537 | | select col_a 1538 | | describe 1539 | 1540 | 1541 | open db.sqlite 1542 | | from table table_1 --as t1 1543 | | join ( 1544 | open db.sqlite 1545 | | from table table_2 1546 | | select col_c 1547 | ) ((field t1.col_a) == (field t2.col_c)) --as t2 --right 1548 | | select col_a 1549 | | describe 1550 | 1551 | 1552 | keybindings default 1553 | 1554 | 1555 | keybindings list -m 1556 | 1557 | 1558 | keybindings list -e -d 1559 | 1560 | 1561 | keybindings list 1562 | 1563 | 1564 | keybindings listen 1565 | 1566 | 1567 | ps | sort-by mem | last | kill $in.pid 1568 | 1569 | 1570 | kill --force 12345 1571 | 1572 | 1573 | kill -s 2 12345 1574 | 1575 | 1576 | col a | last 1577 | 1578 | 1579 | [[a b]; [1 2] [3 4]] | into df | last 1 1580 | 1581 | 1582 | [1,2,3] | last 2 1583 | 1584 | 1585 | [1,2,3] | last 1586 | 1587 | 1588 | echo [1 2 3 4 5] | length 1589 | 1590 | 1591 | cal | length -c 1592 | 1593 | 1594 | let x = 10 1595 | 1596 | 1597 | let x = 10 + 100 1598 | 1599 | 1600 | let x = if false { -1 } else { 1 } 1601 | 1602 | 1603 | let-env MY_ENV_VAR = 1; $env.MY_ENV_VAR 1604 | 1605 | 1606 | open db.sqlite 1607 | | from table table_a 1608 | | select a 1609 | | limit 10 1610 | | describe 1611 | 1612 | 1613 | echo $'two(char nl)lines' | lines 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | lit 2 | into nu 1620 | 1621 | 1622 | {NAME: ABE, AGE: UNKNOWN} | load-env; echo $env.NAME 1623 | 1624 | 1625 | load-env {NAME: ABE, AGE: UNKNOWN}; echo $env.NAME 1626 | 1627 | 1628 | [Abc aBc abC] | into df | lowercase 1629 | 1630 | 1631 | ls 1632 | 1633 | 1634 | ls subdir 1635 | 1636 | 1637 | ls -f .. 1638 | 1639 | 1640 | ls *.rs 1641 | 1642 | 1643 | ls -s | where name !~ bar 1644 | 1645 | 1646 | ls ~ | where type == dir 1647 | 1648 | 1649 | ls -s ~ | where type == dir && modified < ((date now) - 7day) 1650 | 1651 | 1652 | ['/path/to/directory' '/path/to/file'] | each { |it| ls -D $it } | flatten 1653 | 1654 | 1655 | let test = ([[a b];[1 2] [3 4]] | into df); 1656 | ls-df 1657 | 1658 | 1659 | [-50 -100.0 25] | math abs 1660 | 1661 | 1662 | [-50 100.0 25] | math avg 1663 | 1664 | 1665 | [1.5 2.3 -3.1] | math ceil 1666 | 1667 | 1668 | '10 / 4' | math eval 1669 | 1670 | 1671 | [1.5 2.3 -3.1] | math floor 1672 | 1673 | 1674 | [-50 100 25] | math max 1675 | 1676 | 1677 | [3 8 9 12 12 15] | math median 1678 | 1679 | 1680 | [-50 100 25] | math min 1681 | 1682 | 1683 | [3 3 9 12 12 15] | math mode 1684 | 1685 | 1686 | [2 3 3 4] | math product 1687 | 1688 | 1689 | [1.5 2.3 -3.1] | math round 1690 | 1691 | 1692 | [1.555 2.333 -3.111] | math round -p 2 1693 | 1694 | 1695 | [9 16] | math sqrt 1696 | 1697 | 1698 | [1 2 3 4 5] | math stddev 1699 | 1700 | 1701 | [1 2 3 4 5] | math stddev -s 1702 | 1703 | 1704 | [1 2 3] | math sum 1705 | 1706 | 1707 | ls | get size | math sum 1708 | 1709 | 1710 | echo [1 2 3 4 5] | math variance 1711 | 1712 | 1713 | [1 2 3 4 5] | math variance -s 1714 | 1715 | 1716 | [[a b]; [6 2] [1 4] [4 1]] | into df | max 1717 | 1718 | 1719 | [[a b]; [one 2] [one 4] [two 1]] 1720 | | into df 1721 | | group-by a 1722 | | agg (col b | max) 1723 | 1724 | 1725 | [[a b]; [6 2] [4 2] [2 2]] | into df | mean 1726 | 1727 | 1728 | [[a b]; [one 2] [one 4] [two 1]] 1729 | | into df 1730 | | group-by a 1731 | | agg (col b | mean) 1732 | 1733 | 1734 | [[a b]; [one 2] [one 4] [two 1]] 1735 | | into df 1736 | | group-by a 1737 | | agg (col b | median) 1738 | 1739 | 1740 | [[a b]; [6 2] [4 2] [2 2]] | into df | median 1741 | 1742 | 1743 | [[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | into df | melt -c [b c] -v [a d] 1744 | 1745 | 1746 | [a b c] | wrap name | merge { [1 2 3] | wrap index } 1747 | 1748 | 1749 | {a: 1, b: 2} | merge { {c: 3} } 1750 | 1751 | 1752 | {a: 1, b: 3} | merge { {b: 2, c: 4} } 1753 | 1754 | 1755 | metadata $a 1756 | 1757 | 1758 | ls | metadata 1759 | 1760 | 1761 | [[a b]; [6 2] [1 4] [4 1]] | into df | min 1762 | 1763 | 1764 | [[a b]; [one 2] [one 4] [two 1]] 1765 | | into df 1766 | | group-by a 1767 | | agg (col b | min) 1768 | 1769 | 1770 | mkdir foo 1771 | 1772 | 1773 | mkdir -s foo/bar foo2 1774 | 1775 | 1776 | module spam { export def foo [] { "foo" } }; use spam foo; foo 1777 | 1778 | 1779 | module foo { export env FOO_ENV { "BAZ" } }; use foo FOO_ENV; $env.FOO_ENV 1780 | 1781 | 1782 | module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR 1783 | 1784 | 1785 | [[name value index]; [foo a 1] [bar b 2] [baz c 3]] | move index --before name 1786 | 1787 | 1788 | [[name value index]; [foo a 1] [bar b 2] [baz c 3]] | move value name --after index 1789 | 1790 | 1791 | { name: foo, value: a, index: 1 } | move name --before index 1792 | 1793 | 1794 | mv before.txt after.txt 1795 | 1796 | 1797 | mv test.txt my/subdirectory 1798 | 1799 | 1800 | mv *.txt my/subdirectory 1801 | 1802 | 1803 | mkdir foo bar; enter foo; enter ../bar; n 1804 | 1805 | 1806 | n 1807 | 1808 | 1809 | col a | n-unique 1810 | 1811 | 1812 | [1 1 2 2 3 3 4] | into df | n-unique 1813 | 1814 | 1815 | nu-check script.nu 1816 | 1817 | 1818 | nu-check --as-module module.nu 1819 | 1820 | 1821 | nu-check -d script.nu 1822 | 1823 | 1824 | open foo.nu | nu-check -d script.nu 1825 | 1826 | 1827 | open module.nu | lines | nu-check -d --as-module module.nu 1828 | 1829 | 1830 | echo $'two(char nl)lines' | nu-check 1831 | 1832 | 1833 | nu-check -a script.nu 1834 | 1835 | 1836 | open foo.nu | lines | nu-check -ad 1837 | 1838 | 1839 | 'let x = 3' | nu-highlight 1840 | 1841 | 1842 | open myfile.json 1843 | 1844 | 1845 | open myfile.json --raw 1846 | 1847 | 1848 | echo 'myfile.txt' | open 1849 | 1850 | 1851 | open myfile.txt --raw | decode utf-8 1852 | 1853 | 1854 | open-db file.sqlite 1855 | 1856 | 1857 | open test.csv 1858 | 1859 | 1860 | open db.sqlite 1861 | | from table table_1 1862 | | select a 1863 | | where ((field a) > 1) 1864 | | or ((field b) == 1) 1865 | | describe 1866 | 1867 | 1868 | open db.sqlite 1869 | | from table table_1 1870 | | select a 1871 | | where ((field a) > 1 | or ((field a) < 10)) 1872 | | or ((field b) == 1) 1873 | | describe 1874 | 1875 | 1876 | (field a) > 1 | or ((field a) < 10) | into nu 1877 | 1878 | 1879 | open db.sqlite 1880 | | from table table_a 1881 | | select a 1882 | | order-by a 1883 | | describe 1884 | 1885 | 1886 | open db.sqlite 1887 | | from table table_a 1888 | | select a 1889 | | order-by a --ascending 1890 | | order-by b 1891 | | describe 1892 | 1893 | 1894 | when ((col a) > 2) 4 | otherwise 5 1895 | 1896 | 1897 | when ((col a) > 2) 4 | when ((col a) < 0) 6 | otherwise 0 1898 | 1899 | 1900 | [[a b]; [6 2] [1 4] [4 1]] 1901 | | into lazy 1902 | | with-column ( 1903 | when ((col a) > 2) 4 | otherwise 5 | as c 1904 | ) 1905 | | with-column ( 1906 | when ((col a) > 5) 10 | when ((col a) < 2) 6 | otherwise 0 | as d 1907 | ) 1908 | | collect 1909 | 1910 | 1911 | fn avg col_a | over col_b | into nu 1912 | 1913 | 1914 | open db.sqlite 1915 | | from table table_a 1916 | | select (fn lead col_a | over col_b) 1917 | | describe 1918 | 1919 | 1920 | module spam { export def foo [] { "foo" } } 1921 | overlay use spam 1922 | overlay hide spam 1923 | 1924 | 1925 | echo 'export alias f = "foo"' | save spam.nu 1926 | overlay use spam.nu 1927 | overlay hide spam 1928 | 1929 | 1930 | module spam { export env FOO { "foo" } } 1931 | overlay use spam 1932 | overlay hide 1933 | 1934 | 1935 | overlay new spam 1936 | cd some-dir 1937 | overlay hide --keep-env [ PWD ] spam 1938 | 1939 | 1940 | module spam { export def foo [] { "foo" } } 1941 | overlay use spam 1942 | overlay list | last 1943 | 1944 | 1945 | overlay new spam 1946 | 1947 | 1948 | module spam { export def foo [] { "foo" } } 1949 | overlay use spam 1950 | foo 1951 | 1952 | 1953 | echo 'export def foo { "foo" }' 1954 | overlay use --prefix spam 1955 | spam foo 1956 | 1957 | 1958 | echo 'export env FOO { "foo" }' | save spam.nu 1959 | overlay use spam.nu 1960 | $env.FOO 1961 | 1962 | 1963 | mkdir foo bar; enter foo; enter ../bar; p 1964 | 1965 | 1966 | p 1967 | 1968 | 1969 | [1 2 3] | par-each { |it| 2 * $it } 1970 | 1971 | 1972 | [1 2 3] | par-each -n { |it| if $it.item == 2 { echo $"found 2 at ($it.index)!"} } 1973 | 1974 | 1975 | echo "hi there" | parse "{foo} {bar}" 1976 | 1977 | 1978 | echo "hi there" | parse -r '(?P\w+) (?P\w+)' 1979 | 1980 | 1981 | echo "foo bar." | parse -r '\s*(?\w+)(?=\.)' 1982 | 1983 | 1984 | echo "foo! bar." | parse -r '(\w+)(?=\.)|(\w+)(?=!)' 1985 | 1986 | 1987 | echo " @another(foo bar) " | parse -r '\s*(?<=[() ])(@\w+)(\([^)]*\))?\s*' 1988 | 1989 | 1990 | echo "abcd" | parse -r '^a(bc(?=d)|b)cd$' 1991 | 1992 | 1993 | '/home/joe/test.txt' | path basename 1994 | 1995 | 1996 | [[name];["/home/joe"]] | path basename -c [ name ] 1997 | 1998 | 1999 | '/home/joe/test.txt' | path basename -r 'spam.png' 2000 | 2001 | 2002 | '/home/joe/code/test.txt' | path dirname 2003 | 2004 | 2005 | ls ('.' | path expand) | path dirname -c [ name ] 2006 | 2007 | 2008 | '/home/joe/code/test.txt' | path dirname -n 2 2009 | 2010 | 2011 | '/home/joe/code/test.txt' | path dirname -n 2 -r /home/viking 2012 | 2013 | 2014 | '/home/joe/todo.txt' | path exists 2015 | 2016 | 2017 | ls | path exists -c [ name ] 2018 | 2019 | 2020 | '/home/joe/foo/../bar' | path expand 2021 | 2022 | 2023 | ls | path expand -c [ name ] 2024 | 2025 | 2026 | 'foo/../bar' | path expand 2027 | 2028 | 2029 | '/home/viking' | path join spam.txt 2030 | 2031 | 2032 | '/home/viking' | path join spams this_spam.txt 2033 | 2034 | 2035 | ls | path join spam.txt -c [ name ] 2036 | 2037 | 2038 | [ '/' 'home' 'viking' 'spam.txt' ] | path join 2039 | 2040 | 2041 | [[ parent stem extension ]; [ '/home/viking' 'spam' 'txt' ]] | path join 2042 | 2043 | 2044 | '/home/viking/spam.txt' | path parse 2045 | 2046 | 2047 | '/home/viking/spam.tar.gz' | path parse -e tar.gz | upsert extension { 'txt' } 2048 | 2049 | 2050 | '/etc/conf.d' | path parse -e '' 2051 | 2052 | 2053 | ls | path parse -c [ name ] 2054 | 2055 | 2056 | '/home/viking' | path relative-to '/home' 2057 | 2058 | 2059 | ls ~ | path relative-to ~ -c [ name ] 2060 | 2061 | 2062 | 'eggs/bacon/sausage/spam' | path relative-to 'eggs/bacon/sausage' 2063 | 2064 | 2065 | '/home/viking/spam.txt' | path split 2066 | 2067 | 2068 | ls ('.' | path expand) | path split -c [ name ] 2069 | 2070 | 2071 | '.' | path type 2072 | 2073 | 2074 | ls | path type -c [ name ] 2075 | 2076 | 2077 | port 3121 4000 2078 | 2079 | 2080 | port 2081 | 2082 | 2083 | post url.com 'body' 2084 | 2085 | 2086 | post -u myuser -p mypass url.com 'body' 2087 | 2088 | 2089 | post -H [my-header-key my-header-value] url.com 2090 | 2091 | 2092 | post -t application/json url.com { field: value } 2093 | 2094 | 2095 | [1,2,3,4] | prepend 0 2096 | 2097 | 2098 | [2,3,4] | prepend [0,1] 2099 | 2100 | 2101 | [2,nu,4,shell] | prepend [0,1,rocks] 2102 | 2103 | 2104 | print "hello world" 2105 | 2106 | 2107 | print (2 + 3) 2108 | 2109 | 2110 | ps 2111 | 2112 | 2113 | ps | sort-by mem | last 5 2114 | 2115 | 2116 | ps | sort-by cpu | last 3 2117 | 2118 | 2119 | ps | where name =~ 'nu' 2120 | 2121 | 2122 | [[a b]; [6 2] [1 4] [4 1]] | into df | quantile 0.5 2123 | 2124 | 2125 | [[a b]; [one 2] [one 4] [two 1]] 2126 | | into df 2127 | | group-by a 2128 | | agg (col b | quantile 0.5) 2129 | 2130 | 2131 | open foo.db | query db "SELECT * FROM Bar" 2132 | 2133 | 2134 | random bool 2135 | 2136 | 2137 | random bool --bias 0.75 2138 | 2139 | 2140 | random chars 2141 | 2142 | 2143 | random chars -l 20 2144 | 2145 | 2146 | random decimal 2147 | 2148 | 2149 | random decimal ..500 2150 | 2151 | 2152 | random decimal 100000.. 2153 | 2154 | 2155 | random decimal (1.0)..(1.1) 2156 | 2157 | 2158 | random dice 2159 | 2160 | 2161 | random dice -d 10 -s 12 2162 | 2163 | 2164 | random integer 2165 | 2166 | 2167 | random integer ..500 2168 | 2169 | 2170 | random integer 100000.. 2171 | 2172 | 2173 | random integer 1..10 2174 | 2175 | 2176 | random uuid 2177 | 2178 | 2179 | [0,1,2,3,4,5] | range 4..5 2180 | 2181 | 2182 | [0,1,2,3,4,5] | range (-2).. 2183 | 2184 | 2185 | [0,1,2,3,4,5] | range (-3)..-2 2186 | 2187 | 2188 | [ 1 2 3 4 ] | reduce {|it, acc| $it + $acc } 2189 | 2190 | 2191 | [ 1 2 3 ] | reduce -n {|it, acc| $acc.item + $it.item } 2192 | 2193 | 2194 | [ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it } 2195 | 2196 | 2197 | [ i o t ] | reduce -f "Arthur, King of the Britons" {|it, acc| $acc | str replace -a $it "X" } 2198 | 2199 | 2200 | [ one longest three bar ] | reduce -n { |it, acc| 2201 | if ($it.item | str length) > ($acc.item | str length) { 2202 | $it.item 2203 | } else { 2204 | $acc.item 2205 | } 2206 | } 2207 | 2208 | 2209 | register -e json ~/.cargo/bin/nu_plugin_query 2210 | 2211 | 2212 | let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register -e json ($plugin); version' 2213 | 2214 | 2215 | ls | reject modified 2216 | 2217 | 2218 | echo {a: 1, b: 2} | reject a 2219 | 2220 | 2221 | echo {a: {b: 3,c: 5}} | reject a.b 2222 | 2223 | 2224 | [[a, b]; [1, 2]] | rename my_column 2225 | 2226 | 2227 | [[a, b, c]; [1, 2, 3]] | rename eggs ham bacon 2228 | 2229 | 2230 | [[a, b, c]; [1, 2, 3]] | rename -c [a ham] 2231 | 2232 | 2233 | [5 6 7 8] | into df | rename '0' new_name 2234 | 2235 | 2236 | [[a b]; [1 2] [3 4]] | into df | rename a a_new 2237 | 2238 | 2239 | [[a b]; [1 2] [3 4]] | into df | rename [a b] [a_new b_new] 2240 | 2241 | 2242 | [abc abc abc] | into df | replace -p ab -r AB 2243 | 2244 | 2245 | [abac abac abac] | into df | replace-all -p a -r A 2246 | 2247 | 2248 | [0,1,2,3] | reverse 2249 | 2250 | 2251 | [[a b]; [6 2] [4 2] [2 2]] | into df | reverse 2252 | 2253 | 2254 | rm file.txt 2255 | 2256 | 2257 | rm --trash file.txt 2258 | 2259 | 2260 | rm --permanent file.txt 2261 | 2262 | 2263 | rm --force file.txt 2264 | 2265 | 2266 | [[a b]; [1 2] [3 4] [5 6]] | roll down 2267 | 2268 | 2269 | [[a b c]; [1 2 3] [4 5 6]] | roll left 2270 | 2271 | 2272 | [[a b c]; [1 2 3] [4 5 6]] | roll left --cells-only 2273 | 2274 | 2275 | [[a b c]; [1 2 3] [4 5 6]] | roll right 2276 | 2277 | 2278 | [[a b c]; [1 2 3] [4 5 6]] | roll right --cells-only 2279 | 2280 | 2281 | [[a b]; [1 2] [3 4] [5 6]] | roll up 2282 | 2283 | 2284 | [1 2 3 4 5] | into df | rolling sum 2 | drop-nulls 2285 | 2286 | 2287 | [1 2 3 4 5] | into df | rolling max 2 | drop-nulls 2288 | 2289 | 2290 | [[a b]; [1 2]] | rotate 2291 | 2292 | 2293 | [[a b]; [1 2] [3 4] [5 6]] | rotate 2294 | 2295 | 2296 | [[a b]; [1 2]] | rotate col_a col_b 2297 | 2298 | 2299 | [[a b]; [1 2]] | rotate --ccw 2300 | 2301 | 2302 | [[a b]; [1 2] [3 4] [5 6]] | rotate --ccw 2303 | 2304 | 2305 | [[a b]; [1 2]] | rotate --ccw col_a col_b 2306 | 2307 | 2308 | run-external "echo" "-n" "hello" 2309 | 2310 | 2311 | [[a b]; [1 2] [3 4]] | into df | sample -n 1 2312 | 2313 | 2314 | [[a b]; [1 2] [3 4] [5 6]] | into df | sample -f 0.5 -e 2315 | 2316 | 2317 | echo 'save me' | save foo.txt 2318 | 2319 | 2320 | echo 'append me' | save --append foo.txt 2321 | 2322 | 2323 | echo { a: 1, b: 2 } | save foo.json 2324 | 2325 | 2326 | open foo.db | schema 2327 | 2328 | 2329 | ls | select name 2330 | 2331 | 2332 | ls | select name size 2333 | 2334 | 2335 | open db.sqlite | into db | select a | describe 2336 | 2337 | 2338 | open db.sqlite 2339 | | into db 2340 | | select (field a | as new_a) b c 2341 | | from table table_1 2342 | | describe 2343 | 2344 | 2345 | [[a b]; [6 2] [4 2] [2 2]] | into df | select a 2346 | 2347 | 2348 | seq 1 10 2349 | 2350 | 2351 | seq 1.0 0.1 2.0 2352 | 2353 | 2354 | seq -s '|' 1 10 2355 | 2356 | 2357 | seq -s '|' -w 1 10 2358 | 2359 | 2360 | seq -s ' | ' -w 1 2 10 2361 | 2362 | 2363 | seq char a e 2364 | 2365 | 2366 | seq char -s '|' a e 2367 | 2368 | 2369 | seq date --days 10 2370 | 2371 | 2372 | seq date --days 10 -r 2373 | 2374 | 2375 | seq date --days 10 -o '%m/%d/%Y' -r 2376 | 2377 | 2378 | seq date -b '2020-01-01' -e '2020-01-10' 2379 | 2380 | 2381 | seq date -b '2020-01-01' -e '2020-01-31' -n 5 2382 | 2383 | 2384 | seq date -o %x -s ':' -d 10 -b '2020-05-01' 2385 | 2386 | 2387 | let s = ([1 2 2 3 3] | into df | shift 2); 2388 | let mask = ($s | is-null); 2389 | $s | set 0 --mask $mask 2390 | 2391 | 2392 | let series = ([4 1 5 2 4 3] | into df); 2393 | let indices = ([0 2] | into df); 2394 | $series | set-with-idx 6 -i $indices 2395 | 2396 | 2397 | [[a b]; [1 2] [3 4]] | into df | shape 2398 | 2399 | 2400 | enter ..; shells 2401 | 2402 | 2403 | shells | where active == true 2404 | 2405 | 2406 | [1 2 2 3 3] | into df | shift 2 | drop-nulls 2407 | 2408 | 2409 | echo [[version patch]; ["1.0.0" false] ["3.0.1" true] ["2.0.0" false]] | shuffle 2410 | 2411 | 2412 | "There are seven words in this sentence" | size 2413 | 2414 | 2415 | '今天天气真好' | size 2416 | 2417 | 2418 | "Amélie Amelie" | size 2419 | 2420 | 2421 | echo [[editions]; [2015] [2018] [2021]] | skip 2 2422 | 2423 | 2424 | echo [2 4 6 8] | skip 2425 | 2426 | 2427 | echo [-2 0 2 -1] | skip until $it > 0 2428 | 2429 | 2430 | echo [-2 0 2 -1] | skip while $it < 0 2431 | 2432 | 2433 | sleep 1sec 2434 | 2435 | 2436 | sleep 1sec 1sec 1sec 2437 | 2438 | 2439 | sleep 1sec; echo done 2440 | 2441 | 2442 | [[a b]; [1 2] [3 4]] | into df | slice 0 1 2443 | 2444 | 2445 | [2 0 1] | sort 2446 | 2447 | 2448 | [2 0 1] | sort -r 2449 | 2450 | 2451 | [betty amy sarah] | sort 2452 | 2453 | 2454 | [betty amy sarah] | sort -r 2455 | 2456 | 2457 | echo [airplane Truck Car] | sort -i 2458 | 2459 | 2460 | echo [airplane Truck Car] | sort -i -r 2461 | 2462 | 2463 | {b: 3, a: 4} | sort 2464 | 2465 | 2466 | {a: 4, b: 3} | sort 2467 | 2468 | 2469 | [[a b]; [6 2] [1 4] [4 1]] | into df | sort-by a 2470 | 2471 | 2472 | [[a b]; [6 2] [1 1] [1 4] [2 4]] | into df | sort-by [a b] -r [false true] 2473 | 2474 | 2475 | [2 0 1] | sort-by 2476 | 2477 | 2478 | [2 0 1] | sort-by -r 2479 | 2480 | 2481 | [betty amy sarah] | sort-by 2482 | 2483 | 2484 | [betty amy sarah] | sort-by -r 2485 | 2486 | 2487 | [test1 test11 test2] | sort-by -n 2488 | 2489 | 2490 | echo [airplane Truck Car] | sort-by -i 2491 | 2492 | 2493 | echo [airplane Truck Car] | sort-by -i -r 2494 | 2495 | 2496 | [[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit -r 2497 | 2498 | 2499 | source foo.nu 2500 | 2501 | 2502 | source ./foo.nu; say-hi 2503 | 2504 | 2505 | source-env foo.nu 2506 | 2507 | 2508 | 'hello' | split chars 2509 | 2510 | 2511 | echo 'a--b--c' | split column '--' 2512 | 2513 | 2514 | echo 'abc' | split column -c '' 2515 | 2516 | 2517 | [a, b, c, d, e, f, g] | split list d 2518 | 2519 | 2520 | [[1,2], [2,3], [3,4]] | split list [2,3] 2521 | 2522 | 2523 | echo 'abc' | split row '' 2524 | 2525 | 2526 | echo 'a--b--c' | split row '--' 2527 | 2528 | 2529 | 'hello world' | split words 2530 | 2531 | 2532 | 'hello to the world' | split words -l 3 2533 | 2534 | 2535 | fetch https://www.gutenberg.org/files/11/11-0.txt | str downcase | split words -l 2 | uniq -c | sort-by count --reverse | first 10 2536 | 2537 | 2538 | 2539 | { 2540 | '2019': [ 2541 | { name: 'andres', lang: 'rb', year: '2019' }, 2542 | { name: 'jt', lang: 'rs', year: '2019' } 2543 | ], 2544 | '2021': [ 2545 | { name: 'storm', lang: 'rs', 'year': '2021' } 2546 | ] 2547 | } | split-by lang 2548 | 2549 | 2550 | 2551 | [[a b]; [one 2] [one 2] [two 1] [two 1]] 2552 | | into df 2553 | | group-by a 2554 | | agg (col b | std) 2555 | 2556 | 2557 | [[a b]; [6 2] [4 2] [2 2]] | into df | std 2558 | 2559 | 2560 | 'NuShell' | str camel-case 2561 | 2562 | 2563 | 'this-is-the-first-case' | str camel-case 2564 | 2565 | 2566 | 'this_is_the_second_case' | str camel-case 2567 | 2568 | 2569 | [[lang, gems]; [nu_test, 100]] | str camel-case lang 2570 | 2571 | 2572 | 'good day' | str capitalize 2573 | 2574 | 2575 | 'anton' | str capitalize 2576 | 2577 | 2578 | [[lang, gems]; [nu_test, 100]] | str capitalize lang 2579 | 2580 | 2581 | ['nu', 'shell'] | str collect 2582 | 2583 | 2584 | ['nu', 'shell'] | str collect '-' 2585 | 2586 | 2587 | 'my_library.rb' | str contains '.rb' 2588 | 2589 | 2590 | 'my_library.rb' | str contains -i '.RB' 2591 | 2592 | 2593 | [[ColA ColB]; [test 100]] | str contains 'e' ColA 2594 | 2595 | 2596 | [[ColA ColB]; [test 100]] | str contains -i 'E' ColA 2597 | 2598 | 2599 | [[ColA ColB]; [test hello]] | str contains 'e' ColA ColB 2600 | 2601 | 2602 | 'hello' | str contains 'banana' 2603 | 2604 | 2605 | [one two three] | str contains o 2606 | 2607 | 2608 | [one two three] | str contains -n o 2609 | 2610 | 2611 | 'nushell' | str distance 'nutshell' 2612 | 2613 | 2614 | 'NU' | str downcase 2615 | 2616 | 2617 | 'TESTa' | str downcase 2618 | 2619 | 2620 | [[ColA ColB]; [Test ABC]] | str downcase ColA 2621 | 2622 | 2623 | [[ColA ColB]; [Test ABC]] | str downcase ColA ColB 2624 | 2625 | 2626 | 'my_library.rb' | str ends-with '.rb' 2627 | 2628 | 2629 | 'my_library.rb' | str ends-with '.txt' 2630 | 2631 | 2632 | 'my_library.rb' | str index-of '.rb' 2633 | 2634 | 2635 | '.rb.rb' | str index-of '.rb' -r '1,' 2636 | 2637 | 2638 | '123456' | str index-of '6' -r ',4' 2639 | 2640 | 2641 | '123456' | str index-of '3' -r '1,4' 2642 | 2643 | 2644 | '123456' | str index-of '3' -r [1 4] 2645 | 2646 | 2647 | '/this/is/some/path/file.txt' | str index-of '/' -e 2648 | 2649 | 2650 | 'NuShell' | str kebab-case 2651 | 2652 | 2653 | 'thisIsTheFirstCase' | str kebab-case 2654 | 2655 | 2656 | 'THIS_IS_THE_SECOND_CASE' | str kebab-case 2657 | 2658 | 2659 | [[lang, gems]; [nuTest, 100]] | str kebab-case lang 2660 | 2661 | 2662 | 'hello' | str length 2663 | 2664 | 2665 | ['hi' 'there'] | str length 2666 | 2667 | 2668 | 'nushell' | str lpad -l 10 -c '*' 2669 | 2670 | 2671 | '123' | str lpad -l 10 -c '0' 2672 | 2673 | 2674 | '123456789' | str lpad -l 3 -c '0' 2675 | 2676 | 2677 | '▉' | str lpad -l 10 -c '▉' 2678 | 2679 | 2680 | 'nu-shell' | str pascal-case 2681 | 2682 | 2683 | 'this-is-the-first-case' | str pascal-case 2684 | 2685 | 2686 | 'this_is_the_second_case' | str pascal-case 2687 | 2688 | 2689 | [[lang, gems]; [nu_test, 100]] | str pascal-case lang 2690 | 2691 | 2692 | 'my_library.rb' | str replace '(.+).rb' '$1.nu' 2693 | 2694 | 2695 | 'abc abc abc' | str replace -a 'b' 'z' 2696 | 2697 | 2698 | [[ColA ColB ColC]; [abc abc ads]] | str replace -a 'b' 'z' ColA ColC 2699 | 2700 | 2701 | 'dogs_$1_cats' | str replace '\$1' '$2' -n 2702 | 2703 | 2704 | 'c:\some\cool\path' | str replace 'c:\some\cool' '~' -s 2705 | 2706 | 2707 | 'abc abc abc' | str replace -a 'b' 'z' -s 2708 | 2709 | 2710 | 'a sucessful b' | str replace '\b([sS])uc(?:cs|s?)e(ed(?:ed|ing|s?)|ss(?:es|ful(?:ly)?|i(?:ons?|ve(?:ly)?)|ors?)?)\b' '${1}ucce$2' 2711 | 2712 | 2713 | 'GHIKK-9+*' | str replace '[*[:xdigit:]+]' 'z' 2714 | 2715 | 2716 | 'Nushell' | str reverse 2717 | 2718 | 2719 | ['Nushell' 'is' 'cool'] | str reverse 2720 | 2721 | 2722 | 'nushell' | str rpad -l 10 -c '*' 2723 | 2724 | 2725 | '123' | str rpad -l 10 -c '0' 2726 | 2727 | 2728 | '123456789' | str rpad -l 3 -c '0' 2729 | 2730 | 2731 | '▉' | str rpad -l 10 -c '▉' 2732 | 2733 | 2734 | "NuShell" | str screaming-snake-case 2735 | 2736 | 2737 | "this_is_the_second_case" | str screaming-snake-case 2738 | 2739 | 2740 | "this-is-the-first-case" | str screaming-snake-case 2741 | 2742 | 2743 | [[lang, gems]; [nu_test, 100]] | str screaming-snake-case lang 2744 | 2745 | 2746 | "NuShell" | str snake-case 2747 | 2748 | 2749 | "this_is_the_second_case" | str snake-case 2750 | 2751 | 2752 | "this-is-the-first-case" | str snake-case 2753 | 2754 | 2755 | [[lang, gems]; [nuTest, 100]] | str snake-case lang 2756 | 2757 | 2758 | 'my_library.rb' | str starts-with 'my' 2759 | 2760 | 2761 | 'Cargo.toml' | str starts-with 'Car' 2762 | 2763 | 2764 | 'Cargo.toml' | str starts-with '.toml' 2765 | 2766 | 2767 | 'good nushell' | str substring [5 12] 2768 | 2769 | 2770 | 'good nushell' | str substring '5,12' 2771 | 2772 | 2773 | 'good nushell' | str substring ',-5' 2774 | 2775 | 2776 | 'good nushell' | str substring '5,' 2777 | 2778 | 2779 | 'good nushell' | str substring ',7' 2780 | 2781 | 2782 | 'nu-shell' | str title-case 2783 | 2784 | 2785 | 'this is a test case' | str title-case 2786 | 2787 | 2788 | [[title, count]; ['nu test', 100]] | str title-case title 2789 | 2790 | 2791 | 'Nu shell ' | str trim 2792 | 2793 | 2794 | '=== Nu shell ===' | str trim -c '=' | str trim 2795 | 2796 | 2797 | ' Nu shell ' | str trim -a 2798 | 2799 | 2800 | ' Nu shell ' | str trim -l 2801 | 2802 | 2803 | '=== Nu shell ===' | str trim -c '=' 2804 | 2805 | 2806 | ' Nu shell ' | str trim -r 2807 | 2808 | 2809 | '=== Nu shell ===' | str trim -r -c '=' 2810 | 2811 | 2812 | 'nu' | str upcase 2813 | 2814 | 2815 | [a ab abc] | into df | str-lengths 2816 | 2817 | 2818 | [abcded abc321 abc123] | into df | str-slice 1 -l 2 2819 | 2820 | 2821 | let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); 2822 | let df = ([$dt $dt] | into df); 2823 | $df | strftime "%Y/%m/%d" 2824 | 2825 | 2826 | [[a b]; [6 2] [1 4] [4 1]] | into df | sum 2827 | 2828 | 2829 | [[a b]; [one 2] [one 4] [two 1]] 2830 | | into df 2831 | | group-by a 2832 | | agg (col b | sum) 2833 | 2834 | 2835 | sys 2836 | 2837 | 2838 | (sys).host | get name 2839 | 2840 | 2841 | (sys).host.name 2842 | 2843 | 2844 | ls | table -n 1 2845 | 2846 | 2847 | echo [[a b]; [1 2] [3 4]] | table 2848 | 2849 | 2850 | [1 2 3] | take 2851 | 2852 | 2853 | [1 2 3] | take 2 2854 | 2855 | 2856 | let df = ([[a b]; [4 1] [5 2] [4 3]] | into df); 2857 | let indices = ([0 2] | into df); 2858 | $df | take $indices 2859 | 2860 | 2861 | let series = ([4 1 5 2 4 3] | into df); 2862 | let indices = ([0 2] | into df); 2863 | $series | take $indices 2864 | 2865 | 2866 | echo [-1 -2 9 1] | take until $it > 0 2867 | 2868 | 2869 | echo [-1 -2 9 1] | take while $it < 0 2870 | 2871 | 2872 | term size 2873 | 2874 | 2875 | term size -c 2876 | 2877 | 2878 | term size -r 2879 | 2880 | 2881 | 2882 | 2883 | 2884 | [[foo bar]; [1 2]] | to csv 2885 | 2886 | 2887 | [[foo bar]; [1 2]] | to csv -s ';' 2888 | 2889 | 2890 | [[a b]; [1 2] [3 4]] | into df | to csv test.csv 2891 | 2892 | 2893 | [[a b]; [1 2] [3 4]] | into df | to csv test.csv -d '|' 2894 | 2895 | 2896 | [[foo bar]; [1 2]] | to html 2897 | 2898 | 2899 | [[foo bar]; [1 2]] | to html --partial 2900 | 2901 | 2902 | [[foo bar]; [1 2]] | to html --dark 2903 | 2904 | 2905 | [a b c] | to json 2906 | 2907 | 2908 | [Joe Bob Sam] | to json -i 4 2909 | 2910 | 2911 | [1 2 3] | to json -r 2912 | 2913 | 2914 | [[foo bar]; [1 2]] | to md 2915 | 2916 | 2917 | [[foo bar]; [1 2]] | to md --pretty 2918 | 2919 | 2920 | [{"H1": "Welcome to Nushell" } [[foo bar]; [1 2]]] | to md --per-element --pretty 2921 | 2922 | 2923 | [0 1 2] | to md --pretty 2924 | 2925 | 2926 | [1 2 3] | to nuon 2927 | 2928 | 2929 | [[a b]; [1 2] [3 4]] | into df | to parquet test.parquet 2930 | 2931 | 2932 | 1 | to text 2933 | 2934 | 2935 | git help -a | lines | find -r '^ ' | to text 2936 | 2937 | 2938 | ls | to text 2939 | 2940 | 2941 | [[foo bar]; ["1" "2"]] | to toml 2942 | 2943 | 2944 | [[foo bar]; [1 2]] | to tsv 2945 | 2946 | 2947 | [[foo bar]; ["1" "2"]] | to url 2948 | 2949 | 2950 | { "note": { "children": [{ "remember": {"attributes" : {}, "children": [Event]}}], "attributes": {} } } | to xml 2951 | 2952 | 2953 | { "note": { "children": [{ "remember": {"attributes" : {}, "children": [Event]}}], "attributes": {} } } | to xml -p 3 2954 | 2955 | 2956 | [[foo bar]; ["1" "2"]] | to yaml 2957 | 2958 | 2959 | touch fixture.json 2960 | 2961 | 2962 | touch a b c 2963 | 2964 | 2965 | touch -m fixture.json 2966 | 2967 | 2968 | touch -m -t 201908241230.30 d e 2969 | 2970 | 2971 | touch -m -d "yesterday" a b c 2972 | 2973 | 2974 | touch -m -r fixture.json d e 2975 | 2976 | 2977 | touch -a -d "August 24, 2019; 12:30:30" fixture.json 2978 | 2979 | 2980 | touch -c -t 201908241230.30 a b c 2981 | 2982 | 2983 | echo [[c1 c2]; [1 2]] | transpose 2984 | 2985 | 2986 | echo [[c1 c2]; [1 2]] | transpose key val 2987 | 2988 | 2989 | echo [[c1 c2]; [1 2]] | transpose -i val 2990 | 2991 | 2992 | echo {c1: 1, c2: 2} | transpose | transpose -i -r -d 2993 | 2994 | 2995 | tutor begin 2996 | 2997 | 2998 | tutor -f "$in" 2999 | 3000 | 3001 | [2 3 3 4] | uniq 3002 | 3003 | 3004 | [1 2 2] | uniq -d 3005 | 3006 | 3007 | [1 2 2] | uniq -u 3008 | 3009 | 3010 | ['hello' 'goodbye' 'Hello'] | uniq -i 3011 | 3012 | 3013 | [1 2 2] | uniq -c 3014 | 3015 | 3016 | [2 2 2 2 2] | into df | unique 3017 | 3018 | 3019 | col a | unique 3020 | 3021 | 3022 | echo {'name': 'nu', 'stars': 5} | update name 'Nushell' 3023 | 3024 | 3025 | echo [[count fruit]; [1 'apple']] | update count {|f| $f.count + 1} 3026 | 3027 | 3028 | [ 3029 | ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"]; 3030 | [ 37, 0, 0, 0, 37, 0, 0] 3031 | ] | update cells { |value| 3032 | if $value == 0 { 3033 | "" 3034 | } else { 3035 | $value 3036 | } 3037 | } 3038 | 3039 | 3040 | [ 3041 | ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"]; 3042 | [ 37, 0, 0, 0, 37, 0, 0] 3043 | ] | update cells -c ["2021-11-18", "2021-11-17"] { |value| 3044 | if $value == 0 { 3045 | "" 3046 | } else { 3047 | $value 3048 | } 3049 | } 3050 | 3051 | 3052 | [Abc aBc abC] | into df | uppercase 3053 | 3054 | 3055 | echo {'name': 'nu', 'stars': 5} | upsert name 'Nushell' 3056 | 3057 | 3058 | echo {'name': 'nu', 'stars': 5} | upsert language 'Rust' 3059 | 3060 | 3061 | echo [[count fruit]; [1 'apple']] | upsert count {|f| $f.count + 1} 3062 | 3063 | 3064 | echo [[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | upsert authors {|a| $a.authors | str collect ','} 3065 | 3066 | 3067 | echo 'http://www.example.com/foo/bar' | url host 3068 | 3069 | 3070 | echo 'http://www.example.com/foo/bar' | url path 3071 | 3072 | 3073 | echo 'http://www.example.com' | url path 3074 | 3075 | 3076 | echo 'http://www.example.com/?foo=bar&baz=quux' | url query 3077 | 3078 | 3079 | echo 'http://www.example.com/' | url query 3080 | 3081 | 3082 | echo 'http://www.example.com' | url scheme 3083 | 3084 | 3085 | echo 'test' | url scheme 3086 | 3087 | 3088 | module spam { export def foo [] { "foo" } }; use spam foo; foo 3089 | 3090 | 3091 | module foo { export env FOO_ENV { "BAZ" } }; use foo FOO_ENV; $env.FOO_ENV 3092 | 3093 | 3094 | module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR 3095 | 3096 | 3097 | [5 5 5 5 6 6] | into df | value-counts 3098 | 3099 | 3100 | [[a b]; [6 2] [4 2] [2 2]] | into df | var 3101 | 3102 | 3103 | [[a b]; [one 2] [one 2] [two 1] [two 1]] 3104 | | into df 3105 | | group-by a 3106 | | agg (col b | var) 3107 | 3108 | 3109 | version 3110 | 3111 | 3112 | let abc = { echo 'hi' }; view-source $abc 3113 | 3114 | 3115 | def hi [] { echo 'Hi!' }; view-source hi 3116 | 3117 | 3118 | def-env foo [] { let-env BAR = 'BAZ' }; view-source foo 3119 | 3120 | 3121 | module mod-foo { export env FOO_ENV { 'BAZ' } }; view-source mod-foo 3122 | 3123 | 3124 | alias hello = echo hi; view-source hello 3125 | 3126 | 3127 | watch . --glob=**/*.rs { cargo test } 3128 | 3129 | 3130 | watch . { |op, path, new_path| $"($op) ($path) ($new_path)"} 3131 | 3132 | 3133 | watch /foo/bar { |op, path| $"($op) - ($path)(char nl)" | save --append changes_in_bar.log } 3134 | 3135 | 3136 | when ((col a) > 2) 4 3137 | 3138 | 3139 | when ((col a) > 2) 4 | when ((col a) < 0) 6 3140 | 3141 | 3142 | [[a b]; [6 2] [1 4] [4 1]] 3143 | | into lazy 3144 | | with-column ( 3145 | when ((col a) > 2) 4 | otherwise 5 | as c 3146 | ) 3147 | | with-column ( 3148 | when ((col a) > 5) 10 | when ((col a) < 2) 6 | otherwise 0 | as d 3149 | ) 3150 | | collect 3151 | 3152 | 3153 | open db.sqlite 3154 | | from table table_1 3155 | | select a 3156 | | where ((field a) > 1) 3157 | | describe 3158 | 3159 | 3160 | ls | where size > 2kb 3161 | 3162 | 3163 | ls | where type == file 3164 | 3165 | 3166 | ls | where name =~ "Car" 3167 | 3168 | 3169 | ls | where modified >= (date now) - 2wk 3170 | 3171 | 3172 | let a = {$in > 3}; [1, 2, 5, 6] | where -b $a 3173 | 3174 | 3175 | which myapp 3176 | 3177 | 3178 | echo [1 2 3 4] | window 2 3179 | 3180 | 3181 | [1, 2, 3, 4, 5, 6, 7, 8] | window 2 --stride 3 3182 | 3183 | 3184 | [[a b]; [1 2] [3 4]] 3185 | | into df 3186 | | with-column ([5 6] | into df) --name c 3187 | 3188 | 3189 | [[a b]; [1 2] [3 4]] 3190 | | into lazy 3191 | | with-column [ 3192 | ((col a) * 2 | as "c") 3193 | ((col a) * 3 | as "d") 3194 | ] 3195 | | collect 3196 | 3197 | 3198 | with-env [MYENV "my env value"] { $env.MYENV } 3199 | 3200 | 3201 | with-env [X Y W Z] { $env.X } 3202 | 3203 | 3204 | with-env [[X W]; [Y Z]] { $env.W } 3205 | 3206 | 3207 | echo '{"X":"Y","W":"Z"}'|from json|with-env $in { echo $env.X $env.W } 3208 | 3209 | 3210 | echo [1 2 3] | wrap num 3211 | 3212 | 3213 | 1..3 | zip 4..6 3214 | 3215 | 3216 | --------------------------------------------------------------------------------