├── .github ├── pull_request_template.md └── workflows │ └── ci.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── crates ├── nu-cli │ ├── Cargo.toml │ └── src │ │ ├── completions.rs │ │ ├── errors.rs │ │ ├── lib.rs │ │ ├── nu_highlight.rs │ │ ├── prompt.rs │ │ ├── syntax_highlight.rs │ │ └── validation.rs ├── nu-color-config │ ├── Cargo.toml │ └── src │ │ ├── color_config.rs │ │ ├── lib.rs │ │ ├── nu_style.rs │ │ └── shape_color.rs ├── nu-command │ ├── Cargo.toml │ ├── assets │ │ └── 228_themes.zip │ ├── build.rs │ ├── src │ │ ├── conversions │ │ │ ├── fmt.rs │ │ │ ├── into │ │ │ │ ├── binary.rs │ │ │ │ ├── bool.rs │ │ │ │ ├── command.rs │ │ │ │ ├── datetime.rs │ │ │ │ ├── decimal.rs │ │ │ │ ├── filesize.rs │ │ │ │ ├── int.rs │ │ │ │ ├── mod.rs │ │ │ │ └── string.rs │ │ │ └── mod.rs │ │ ├── core_commands │ │ │ ├── alias.rs │ │ │ ├── debug.rs │ │ │ ├── def.rs │ │ │ ├── def_env.rs │ │ │ ├── describe.rs │ │ │ ├── do_.rs │ │ │ ├── echo.rs │ │ │ ├── error_make.rs │ │ │ ├── export.rs │ │ │ ├── export_def.rs │ │ │ ├── export_def_env.rs │ │ │ ├── export_env.rs │ │ │ ├── for_.rs │ │ │ ├── help.rs │ │ │ ├── hide.rs │ │ │ ├── history.rs │ │ │ ├── if_.rs │ │ │ ├── ignore.rs │ │ │ ├── let_.rs │ │ │ ├── metadata.rs │ │ │ ├── mod.rs │ │ │ ├── module.rs │ │ │ ├── register.rs │ │ │ ├── source.rs │ │ │ ├── tutor.rs │ │ │ ├── use_.rs │ │ │ └── version.rs │ │ ├── dataframe │ │ │ ├── README.md │ │ │ ├── eager │ │ │ │ ├── aggregate.rs │ │ │ │ ├── append.rs │ │ │ │ ├── column.rs │ │ │ │ ├── command.rs │ │ │ │ ├── describe.rs │ │ │ │ ├── drop.rs │ │ │ │ ├── drop_duplicates.rs │ │ │ │ ├── drop_nulls.rs │ │ │ │ ├── dtypes.rs │ │ │ │ ├── dummies.rs │ │ │ │ ├── filter_with.rs │ │ │ │ ├── first.rs │ │ │ │ ├── get.rs │ │ │ │ ├── groupby.rs │ │ │ │ ├── join.rs │ │ │ │ ├── last.rs │ │ │ │ ├── melt.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── open.rs │ │ │ │ ├── pivot.rs │ │ │ │ ├── rename.rs │ │ │ │ ├── sample.rs │ │ │ │ ├── shape.rs │ │ │ │ ├── slice.rs │ │ │ │ ├── sort.rs │ │ │ │ ├── take.rs │ │ │ │ ├── to_csv.rs │ │ │ │ ├── to_df.rs │ │ │ │ ├── to_nu.rs │ │ │ │ ├── to_parquet.rs │ │ │ │ └── with_column.rs │ │ │ ├── mod.rs │ │ │ ├── series │ │ │ │ ├── all_false.rs │ │ │ │ ├── all_true.rs │ │ │ │ ├── arg_max.rs │ │ │ │ ├── arg_min.rs │ │ │ │ ├── cumulative.rs │ │ │ │ ├── date │ │ │ │ │ ├── get_day.rs │ │ │ │ │ ├── get_hour.rs │ │ │ │ │ ├── get_minute.rs │ │ │ │ │ ├── get_month.rs │ │ │ │ │ ├── get_nanosecond.rs │ │ │ │ │ ├── get_ordinal.rs │ │ │ │ │ ├── get_second.rs │ │ │ │ │ ├── get_week.rs │ │ │ │ │ ├── get_weekday.rs │ │ │ │ │ ├── get_year.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── indexes │ │ │ │ │ ├── arg_sort.rs │ │ │ │ │ ├── arg_true.rs │ │ │ │ │ ├── arg_unique.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── set_with_idx.rs │ │ │ │ ├── masks │ │ │ │ │ ├── is_duplicated.rs │ │ │ │ │ ├── is_in.rs │ │ │ │ │ ├── is_not_null.rs │ │ │ │ │ ├── is_null.rs │ │ │ │ │ ├── is_unique.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── not.rs │ │ │ │ │ └── set.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── n_null.rs │ │ │ │ ├── n_unique.rs │ │ │ │ ├── rename.rs │ │ │ │ ├── rolling.rs │ │ │ │ ├── shift.rs │ │ │ │ ├── string │ │ │ │ │ ├── concatenate.rs │ │ │ │ │ ├── contains.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── replace.rs │ │ │ │ │ ├── replace_all.rs │ │ │ │ │ ├── str_lengths.rs │ │ │ │ │ ├── str_slice.rs │ │ │ │ │ ├── strftime.rs │ │ │ │ │ ├── to_lowercase.rs │ │ │ │ │ └── to_uppercase.rs │ │ │ │ ├── unique.rs │ │ │ │ └── value_counts.rs │ │ │ ├── test_dataframe.rs │ │ │ └── values │ │ │ │ ├── mod.rs │ │ │ │ ├── nu_dataframe │ │ │ │ ├── between_values.rs │ │ │ │ ├── conversion.rs │ │ │ │ ├── custom_value.rs │ │ │ │ ├── mod.rs │ │ │ │ └── operations.rs │ │ │ │ ├── nu_groupby │ │ │ │ ├── custom_value.rs │ │ │ │ └── mod.rs │ │ │ │ └── utils.rs │ │ ├── date │ │ │ ├── date_.rs │ │ │ ├── format.rs │ │ │ ├── humanize.rs │ │ │ ├── list_timezone.rs │ │ │ ├── mod.rs │ │ │ ├── now.rs │ │ │ ├── parser.rs │ │ │ ├── to_table.rs │ │ │ ├── to_timezone.rs │ │ │ └── utils.rs │ │ ├── default_context.rs │ │ ├── env │ │ │ ├── env_command.rs │ │ │ ├── let_env.rs │ │ │ ├── load_env.rs │ │ │ ├── mod.rs │ │ │ └── with_env.rs │ │ ├── example_test.rs │ │ ├── experimental │ │ │ ├── git.rs │ │ │ ├── git_checkout.rs │ │ │ ├── list_git_branches.rs │ │ │ ├── mod.rs │ │ │ └── view_source.rs │ │ ├── filesystem │ │ │ ├── cd.rs │ │ │ ├── cp.rs │ │ │ ├── ls.rs │ │ │ ├── mkdir.rs │ │ │ ├── mod.rs │ │ │ ├── mv.rs │ │ │ ├── open.rs │ │ │ ├── rm.rs │ │ │ ├── save.rs │ │ │ ├── touch.rs │ │ │ └── util.rs │ │ ├── filters │ │ │ ├── all.rs │ │ │ ├── any.rs │ │ │ ├── append.rs │ │ │ ├── collect.rs │ │ │ ├── columns.rs │ │ │ ├── compact.rs │ │ │ ├── default.rs │ │ │ ├── drop │ │ │ │ ├── column.rs │ │ │ │ ├── drop_.rs │ │ │ │ ├── mod.rs │ │ │ │ └── nth.rs │ │ │ ├── each.rs │ │ │ ├── each_group.rs │ │ │ ├── each_window.rs │ │ │ ├── empty.rs │ │ │ ├── every.rs │ │ │ ├── find.rs │ │ │ ├── first.rs │ │ │ ├── flatten.rs │ │ │ ├── get.rs │ │ │ ├── group_by.rs │ │ │ ├── keep │ │ │ │ ├── keep_.rs │ │ │ │ ├── keep_until.rs │ │ │ │ ├── keep_while.rs │ │ │ │ └── mod.rs │ │ │ ├── last.rs │ │ │ ├── length.rs │ │ │ ├── lines.rs │ │ │ ├── merge.rs │ │ │ ├── mod.rs │ │ │ ├── move_.rs │ │ │ ├── nth.rs │ │ │ ├── par_each.rs │ │ │ ├── par_each_group.rs │ │ │ ├── prepend.rs │ │ │ ├── range.rs │ │ │ ├── reduce.rs │ │ │ ├── reject.rs │ │ │ ├── rename.rs │ │ │ ├── reverse.rs │ │ │ ├── rotate.rs │ │ │ ├── select.rs │ │ │ ├── shuffle.rs │ │ │ ├── skip │ │ │ │ ├── mod.rs │ │ │ │ ├── skip_.rs │ │ │ │ ├── skip_until.rs │ │ │ │ └── skip_while.rs │ │ │ ├── sort_by.rs │ │ │ ├── split_by.rs │ │ │ ├── transpose.rs │ │ │ ├── uniq.rs │ │ │ ├── update.rs │ │ │ ├── update_cells.rs │ │ │ ├── where_.rs │ │ │ ├── wrap.rs │ │ │ └── zip_.rs │ │ ├── formats │ │ │ ├── from │ │ │ │ ├── command.rs │ │ │ │ ├── csv.rs │ │ │ │ ├── delimited.rs │ │ │ │ ├── eml.rs │ │ │ │ ├── ics.rs │ │ │ │ ├── ini.rs │ │ │ │ ├── json.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── ods.rs │ │ │ │ ├── ssv.rs │ │ │ │ ├── toml.rs │ │ │ │ ├── tsv.rs │ │ │ │ ├── url.rs │ │ │ │ ├── vcf.rs │ │ │ │ ├── xlsx.rs │ │ │ │ ├── xml.rs │ │ │ │ └── yaml.rs │ │ │ ├── mod.rs │ │ │ └── to │ │ │ │ ├── command.rs │ │ │ │ ├── csv.rs │ │ │ │ ├── delimited.rs │ │ │ │ ├── html.rs │ │ │ │ ├── json.rs │ │ │ │ ├── md.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── toml.rs │ │ │ │ ├── tsv.rs │ │ │ │ ├── url.rs │ │ │ │ ├── xml.rs │ │ │ │ └── yaml.rs │ │ ├── generators │ │ │ ├── cal.rs │ │ │ ├── mod.rs │ │ │ ├── seq.rs │ │ │ └── seq_date.rs │ │ ├── hash │ │ │ ├── base64.rs │ │ │ ├── generic_digest.rs │ │ │ ├── hash_.rs │ │ │ ├── md5.rs │ │ │ ├── mod.rs │ │ │ └── sha256.rs │ │ ├── lib.rs │ │ ├── math │ │ │ ├── abs.rs │ │ │ ├── avg.rs │ │ │ ├── ceil.rs │ │ │ ├── eval.rs │ │ │ ├── floor.rs │ │ │ ├── math_.rs │ │ │ ├── max.rs │ │ │ ├── median.rs │ │ │ ├── min.rs │ │ │ ├── mod.rs │ │ │ ├── mode.rs │ │ │ ├── product.rs │ │ │ ├── reducers.rs │ │ │ ├── round.rs │ │ │ ├── sqrt.rs │ │ │ ├── stddev.rs │ │ │ ├── sum.rs │ │ │ ├── utils.rs │ │ │ └── variance.rs │ │ ├── network │ │ │ ├── fetch.rs │ │ │ ├── mod.rs │ │ │ └── url │ │ │ │ ├── host.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── path.rs │ │ │ │ ├── query.rs │ │ │ │ ├── scheme.rs │ │ │ │ └── url_.rs │ │ ├── path │ │ │ ├── basename.rs │ │ │ ├── dirname.rs │ │ │ ├── exists.rs │ │ │ ├── expand.rs │ │ │ ├── join.rs │ │ │ ├── mod.rs │ │ │ ├── parse.rs │ │ │ ├── path_.rs │ │ │ ├── relative_to.rs │ │ │ ├── split.rs │ │ │ └── type.rs │ │ ├── platform │ │ │ ├── ansi │ │ │ │ ├── ansi_.rs │ │ │ │ ├── gradient.rs │ │ │ │ ├── mod.rs │ │ │ │ └── strip.rs │ │ │ ├── clear.rs │ │ │ ├── dir_info.rs │ │ │ ├── du.rs │ │ │ ├── input.rs │ │ │ ├── kill.rs │ │ │ ├── mod.rs │ │ │ ├── reedline_commands │ │ │ │ ├── keybindings.rs │ │ │ │ ├── keybindings_default.rs │ │ │ │ ├── keybindings_list.rs │ │ │ │ ├── keybindings_listen.rs │ │ │ │ └── mod.rs │ │ │ ├── sleep.rs │ │ │ └── term_size.rs │ │ ├── random │ │ │ ├── bool.rs │ │ │ ├── chars.rs │ │ │ ├── decimal.rs │ │ │ ├── dice.rs │ │ │ ├── integer.rs │ │ │ ├── mod.rs │ │ │ ├── random_.rs │ │ │ └── uuid.rs │ │ ├── shells │ │ │ ├── enter.rs │ │ │ ├── exit.rs │ │ │ ├── g.rs │ │ │ ├── mod.rs │ │ │ ├── n.rs │ │ │ ├── p.rs │ │ │ └── shells_.rs │ │ ├── strings │ │ │ ├── build_string.rs │ │ │ ├── char_.rs │ │ │ ├── decode.rs │ │ │ ├── detect_columns.rs │ │ │ ├── format │ │ │ │ ├── command.rs │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ ├── parse.rs │ │ │ ├── size.rs │ │ │ ├── split │ │ │ │ ├── chars.rs │ │ │ │ ├── column.rs │ │ │ │ ├── command.rs │ │ │ │ ├── mod.rs │ │ │ │ └── row.rs │ │ │ └── str_ │ │ │ │ ├── capitalize.rs │ │ │ │ ├── case │ │ │ │ ├── camel_case.rs │ │ │ │ ├── kebab_case.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── pascal_case.rs │ │ │ │ ├── screaming_snake_case.rs │ │ │ │ ├── snake_case.rs │ │ │ │ └── str_.rs │ │ │ │ ├── collect.rs │ │ │ │ ├── contains.rs │ │ │ │ ├── downcase.rs │ │ │ │ ├── ends_with.rs │ │ │ │ ├── find_replace.rs │ │ │ │ ├── index_of.rs │ │ │ │ ├── length.rs │ │ │ │ ├── lpad.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── reverse.rs │ │ │ │ ├── rpad.rs │ │ │ │ ├── starts_with.rs │ │ │ │ ├── substring.rs │ │ │ │ ├── trim │ │ │ │ ├── mod.rs │ │ │ │ └── trim_.rs │ │ │ │ └── upcase.rs │ │ ├── system │ │ │ ├── benchmark.rs │ │ │ ├── exec.rs │ │ │ ├── mod.rs │ │ │ ├── ps.rs │ │ │ ├── run_external.rs │ │ │ ├── sys.rs │ │ │ └── which_.rs │ │ └── viewers │ │ │ ├── griddle.rs │ │ │ ├── icons.rs │ │ │ ├── mod.rs │ │ │ └── table.rs │ └── tests │ │ ├── commands │ │ ├── all.rs │ │ ├── any.rs │ │ ├── append.rs │ │ ├── cal.rs │ │ ├── cd.rs │ │ ├── compact.rs │ │ ├── cp.rs │ │ ├── def.rs │ │ ├── default.rs │ │ ├── drop.rs │ │ ├── each.rs │ │ ├── echo.rs │ │ ├── empty.rs │ │ ├── enter.rs │ │ ├── every.rs │ │ ├── find.rs │ │ ├── first.rs │ │ ├── flatten.rs │ │ ├── format.rs │ │ ├── get.rs │ │ ├── group_by.rs │ │ ├── hash_ │ │ │ └── mod.rs │ │ ├── headers.rs │ │ ├── help.rs │ │ ├── histogram.rs │ │ ├── into_filesize.rs │ │ ├── into_int.rs │ │ ├── keep │ │ │ ├── mod.rs │ │ │ ├── rows.rs │ │ │ ├── until.rs │ │ │ └── while_.rs │ │ ├── last.rs │ │ ├── length.rs │ │ ├── lines.rs │ │ ├── ls.rs │ │ ├── math │ │ │ ├── avg.rs │ │ │ ├── eval.rs │ │ │ ├── median.rs │ │ │ ├── mod.rs │ │ │ ├── round.rs │ │ │ ├── sqrt.rs │ │ │ └── sum.rs │ │ ├── merge.rs │ │ ├── mkdir.rs │ │ ├── mod.rs │ │ ├── move_ │ │ │ ├── column.rs │ │ │ ├── mod.rs │ │ │ └── mv.rs │ │ ├── nth.rs │ │ ├── open.rs │ │ ├── parse.rs │ │ ├── path │ │ │ ├── basename.rs │ │ │ ├── dirname.rs │ │ │ ├── exists.rs │ │ │ ├── expand.rs │ │ │ ├── join.rs │ │ │ ├── mod.rs │ │ │ ├── parse.rs │ │ │ ├── split.rs │ │ │ └── type_.rs │ │ ├── prepend.rs │ │ ├── random │ │ │ ├── bool.rs │ │ │ ├── chars.rs │ │ │ ├── decimal.rs │ │ │ ├── dice.rs │ │ │ ├── integer.rs │ │ │ ├── mod.rs │ │ │ └── uuid.rs │ │ ├── range.rs │ │ ├── reduce.rs │ │ ├── rename.rs │ │ ├── reverse.rs │ │ ├── rm.rs │ │ ├── roll.rs │ │ ├── rotate.rs │ │ ├── save.rs │ │ ├── select.rs │ │ ├── semicolon.rs │ │ ├── skip │ │ │ ├── mod.rs │ │ │ ├── until.rs │ │ │ └── while_.rs │ │ ├── sort_by.rs │ │ ├── source.rs │ │ ├── split_by.rs │ │ ├── split_column.rs │ │ ├── split_row.rs │ │ ├── str_ │ │ │ ├── collect.rs │ │ │ ├── into_string.rs │ │ │ └── mod.rs │ │ ├── touch.rs │ │ ├── uniq.rs │ │ ├── update.rs │ │ ├── where_.rs │ │ ├── which.rs │ │ ├── with_env.rs │ │ ├── wrap.rs │ │ └── zip.rs │ │ ├── format_conversions │ │ ├── bson.rs │ │ ├── csv.rs │ │ ├── eml.rs │ │ ├── html.rs │ │ ├── ics.rs │ │ ├── json.rs │ │ ├── markdown.rs │ │ ├── mod.rs │ │ ├── ods.rs │ │ ├── sqlite.rs │ │ ├── ssv.rs │ │ ├── toml.rs │ │ ├── tsv.rs │ │ ├── url.rs │ │ ├── vcf.rs │ │ ├── xlsx.rs │ │ ├── xml.rs │ │ └── yaml.rs │ │ └── main.rs ├── nu-engine │ ├── Cargo.toml │ └── src │ │ ├── call_ext.rs │ │ ├── column.rs │ │ ├── documentation.rs │ │ ├── env.rs │ │ ├── eval.rs │ │ ├── glob_from.rs │ │ └── lib.rs ├── nu-json │ ├── Cargo.toml │ ├── LICENSE │ ├── src │ │ ├── builder.rs │ │ ├── de.rs │ │ ├── error.rs │ │ ├── lib.rs │ │ ├── ser.rs │ │ ├── util.rs │ │ └── value.rs │ └── tests │ │ └── main.rs ├── nu-parser │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── errors.rs │ │ ├── flatten.rs │ │ ├── lex.rs │ │ ├── lib.rs │ │ ├── lite_parse.rs │ │ ├── parse_keywords.rs │ │ ├── parser.rs │ │ └── type_check.rs │ └── tests │ │ ├── test_lex.rs │ │ ├── test_lite_parser.rs │ │ └── test_parser.rs ├── nu-path │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── dots.rs │ │ ├── expansions.rs │ │ ├── helpers.rs │ │ ├── lib.rs │ │ ├── tilde.rs │ │ └── util.rs │ └── tests │ │ ├── mod.rs │ │ └── util.rs ├── nu-plugin │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── plugin │ │ ├── declaration.rs │ │ ├── is_plugin │ │ └── mod.rs │ │ ├── plugin_capnp.rs │ │ ├── protocol │ │ ├── evaluated_call.rs │ │ └── mod.rs │ │ └── serializers │ │ ├── capnp │ │ ├── call.rs │ │ ├── mod.rs │ │ ├── plugin_call.rs │ │ ├── schema │ │ │ └── plugin.capnp │ │ ├── signature.rs │ │ └── value.rs │ │ ├── json.rs │ │ └── mod.rs ├── nu-pretty-hex │ ├── Cargo.lock │ ├── Cargo.toml │ ├── LICENSE │ ├── README.md │ ├── src │ │ ├── lib.rs │ │ ├── main.rs │ │ └── pretty_hex.rs │ └── tests │ │ ├── 256.txt │ │ ├── data │ │ └── tests.rs ├── nu-protocol │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── ast │ │ │ ├── block.rs │ │ │ ├── call.rs │ │ │ ├── cell_path.rs │ │ │ ├── expr.rs │ │ │ ├── expression.rs │ │ │ ├── import_pattern.rs │ │ │ ├── mod.rs │ │ │ ├── operator.rs │ │ │ ├── pipeline.rs │ │ │ └── statement.rs │ │ ├── config.rs │ │ ├── engine │ │ │ ├── call_info.rs │ │ │ ├── capture_block.rs │ │ │ ├── command.rs │ │ │ ├── engine_state.rs │ │ │ ├── mod.rs │ │ │ └── stack.rs │ │ ├── example.rs │ │ ├── exportable.rs │ │ ├── id.rs │ │ ├── lib.rs │ │ ├── overlay.rs │ │ ├── pipeline_data.rs │ │ ├── shell_error.rs │ │ ├── signature.rs │ │ ├── span.rs │ │ ├── syntax_shape.rs │ │ ├── ty.rs │ │ └── value │ │ │ ├── custom_value.rs │ │ │ ├── from.rs │ │ │ ├── from_value.rs │ │ │ ├── mod.rs │ │ │ ├── range.rs │ │ │ ├── stream.rs │ │ │ └── unit.rs │ └── tests │ │ ├── test_signature.rs │ │ └── test_value.rs ├── nu-system │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── LICENSE │ └── src │ │ ├── lib.rs │ │ ├── linux.rs │ │ ├── macos.rs │ │ ├── main.rs │ │ └── windows.rs ├── nu-table │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── table.rs │ │ └── wrap.rs ├── nu-term-grid │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ ├── grid.rs │ │ ├── lib.rs │ │ └── main.rs ├── nu-test-support │ ├── Cargo.toml │ └── src │ │ ├── commands.rs │ │ ├── fs.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── playground.rs │ │ └── playground │ │ ├── director.rs │ │ ├── matchers.rs │ │ ├── nu_process.rs │ │ ├── play.rs │ │ └── tests.rs ├── nu_plugin_example │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── example.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ └── nu │ │ └── mod.rs ├── nu_plugin_gstat │ ├── Cargo.toml │ └── src │ │ ├── gstat.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ └── nu │ │ └── mod.rs ├── nu_plugin_inc │ ├── Cargo.toml │ └── src │ │ ├── inc.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ └── nu │ │ └── mod.rs ├── nu_plugin_python │ └── plugin.py └── nu_plugin_query │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── main.rs │ ├── nu │ └── mod.rs │ ├── query.rs │ ├── query_json.rs │ ├── query_web.rs │ ├── query_xml.rs │ └── web_tables.rs ├── docs ├── 3rd_Party_Prompts.md ├── Environment_Variables.md ├── How_To_Coloring_and_Theming.md ├── Modules_and_Overlays.md └── README.md ├── src ├── commands.rs ├── config_files.rs ├── eval_file.rs ├── logger.rs ├── main.rs ├── plugins │ ├── nu_plugin_core_example.rs │ ├── nu_plugin_core_inc.rs │ ├── nu_plugin_extra_gstat.rs │ └── nu_plugin_extra_query.rs ├── prompt_update.rs ├── reedline_config.rs ├── repl.rs ├── test_bins.rs ├── tests.rs ├── tests │ ├── test_conditionals.rs │ ├── test_converters.rs │ ├── test_custom_commands.rs │ ├── test_engine.rs │ ├── test_env.rs │ ├── test_hiding.rs │ ├── test_iteration.rs │ ├── test_math.rs │ ├── test_modules.rs │ ├── test_parser.rs │ ├── test_ranges.rs │ ├── test_strings.rs │ ├── test_table_operations.rs │ └── test_type_check.rs └── utils.rs └── tests ├── assets └── nu_json │ ├── charset_result.hjson │ ├── charset_result.json │ ├── charset_test.hjson │ ├── comments_result.hjson │ ├── comments_result.json │ ├── comments_test.hjson │ ├── empty_result.hjson │ ├── empty_result.json │ ├── empty_test.hjson │ ├── failCharset1_test.hjson │ ├── failJSON02_test.json │ ├── failJSON05_test.json │ ├── failJSON06_test.json │ ├── failJSON07_test.json │ ├── failJSON08_test.json │ ├── failJSON10_test.json │ ├── failJSON11_test.json │ ├── failJSON12_test.json │ ├── failJSON13_test.json │ ├── failJSON14_test.json │ ├── failJSON15_test.json │ ├── failJSON16_test.json │ ├── failJSON17_test.json │ ├── failJSON19_test.json │ ├── failJSON20_test.json │ ├── failJSON21_test.json │ ├── failJSON22_test.json │ ├── failJSON23_test.json │ ├── failJSON24_test.json │ ├── failJSON26_test.json │ ├── failJSON28_test.json │ ├── failJSON29_test.json │ ├── failJSON30_test.json │ ├── failJSON31_test.json │ ├── failJSON32_test.json │ ├── failJSON33_test.json │ ├── failJSON34_test.json │ ├── failKey1_test.hjson │ ├── failKey2_test.hjson │ ├── failKey3_test.hjson │ ├── failKey4_test.hjson │ ├── failMLStr1_test.hjson │ ├── failObj1_test.hjson │ ├── failObj2_test.hjson │ ├── failObj3_test.hjson │ ├── failStr1a_test.hjson │ ├── failStr1b_test.hjson │ ├── failStr1c_test.hjson │ ├── failStr1d_test.hjson │ ├── failStr2a_test.hjson │ ├── failStr2b_test.hjson │ ├── failStr2c_test.hjson │ ├── failStr2d_test.hjson │ ├── failStr3a_test.hjson │ ├── failStr3b_test.hjson │ ├── failStr3c_test.hjson │ ├── failStr3d_test.hjson │ ├── failStr4a_test.hjson │ ├── failStr4b_test.hjson │ ├── failStr4c_test.hjson │ ├── failStr4d_test.hjson │ ├── failStr5a_test.hjson │ ├── failStr5b_test.hjson │ ├── failStr5c_test.hjson │ ├── failStr5d_test.hjson │ ├── failStr6a_test.hjson │ ├── failStr6b_test.hjson │ ├── failStr6c_test.hjson │ ├── failStr6d_test.hjson │ ├── kan_result.hjson │ ├── kan_result.json │ ├── kan_test.hjson │ ├── keys_result.hjson │ ├── keys_result.json │ ├── keys_test.hjson │ ├── oa_result.hjson │ ├── oa_result.json │ ├── oa_test.hjson │ ├── pass1_result.hjson │ ├── pass1_result.json │ ├── pass1_test.json │ ├── pass2_result.hjson │ ├── pass2_result.json │ ├── pass2_test.json │ ├── pass3_result.hjson │ ├── pass3_result.json │ ├── pass3_test.json │ ├── pass4_result.hjson │ ├── pass4_result.json │ ├── pass4_test.json │ ├── passSingle_result.hjson │ ├── passSingle_result.json │ ├── passSingle_test.hjson │ ├── root_result.hjson │ ├── root_result.json │ ├── root_test.hjson │ ├── stringify1_result.hjson │ ├── stringify1_result.json │ ├── stringify1_test.hjson │ ├── strings_result.hjson │ ├── strings_result.json │ ├── strings_test.hjson │ ├── testlist.txt │ ├── trail_result.hjson │ ├── trail_result.json │ └── trail_test.hjson ├── fixtures ├── formats │ ├── appveyor.yml │ ├── caco3_plastics.csv │ ├── caco3_plastics.tsv │ ├── cargo_sample.toml │ ├── jonathan.xml │ ├── lines_test.txt │ ├── random_numbers.csv │ ├── sample-ls-output.json │ ├── sample-ps-output.json │ ├── sample-simple.json │ ├── sample-sys-output.json │ ├── sample.bson │ ├── sample.db │ ├── sample.eml │ ├── sample.ini │ ├── sample.url │ ├── sample_data.ods │ ├── sample_data.xlsx │ ├── sample_headers.xlsx │ ├── script.nu │ ├── script_multiline.nu │ ├── sgml_description.json │ └── utf16.ini └── playground │ └── config │ ├── default.toml │ └── startup.toml ├── main.rs ├── path ├── canonicalize.rs ├── expand_path.rs └── mod.rs ├── plugins ├── core_inc.rs └── mod.rs └── shell ├── environment ├── env.rs ├── mod.rs └── nu_env.rs ├── mod.rs └── pipeline ├── commands ├── external.rs ├── internal.rs └── mod.rs └── mod.rs /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | (description of your pull request here) 4 | 5 | # Tests 6 | 7 | Make sure you've run and fixed any issues with these commands: 8 | 9 | - [ ] `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) 10 | - [ ] `cargo clippy --all --all-features -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style 11 | - [ ] `cargo build; cargo test --all --all-features` to check that all the tests pass 12 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: [pull_request] 2 | 3 | name: Continuous integration 4 | 5 | jobs: 6 | ci: 7 | strategy: 8 | matrix: 9 | platform: [ubuntu-latest, macos-latest, windows-latest] 10 | rust: 11 | - stable 12 | 13 | runs-on: ${{ matrix.platform }} 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - uses: actions-rs/toolchain@v1 19 | with: 20 | profile: minimal 21 | toolchain: ${{ matrix.rust }} 22 | override: true 23 | components: rustfmt, clippy 24 | 25 | - uses: actions-rs/cargo@v1 26 | with: 27 | command: build 28 | 29 | - uses: actions-rs/cargo@v1 30 | with: 31 | command: test 32 | args: --all --all-features 33 | 34 | - uses: actions-rs/cargo@v1 35 | with: 36 | command: fmt 37 | args: --all -- --check 38 | 39 | - uses: actions-rs/cargo@v1 40 | with: 41 | command: clippy 42 | args: --all --all-features -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | history.txt 2 | /target 3 | /.vscode 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOTE: Engine-q is merged into Nushell 2 | 3 | Please use https://github.com/nushell/nushell 4 | -------------------------------------------------------------------------------- /crates/nu-cli/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-cli" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | nu-engine = { path = "../nu-engine" } 8 | nu-path = { path = "../nu-path" } 9 | nu-parser = { path = "../nu-parser" } 10 | nu-protocol = { path = "../nu-protocol" } 11 | # nu-ansi-term = { path = "../nu-ansi-term" } 12 | nu-ansi-term = "0.42.0" 13 | nu-color-config = { path = "../nu-color-config" } 14 | 15 | miette = { version = "3.0.0", features = ["fancy"] } 16 | thiserror = "1.0.29" 17 | reedline = { git = "https://github.com/nushell/reedline", branch = "main" } 18 | 19 | log = "0.4" 20 | is_executable = "1.0.1" 21 | -------------------------------------------------------------------------------- /crates/nu-cli/src/errors.rs: -------------------------------------------------------------------------------- 1 | use miette::{LabeledSpan, MietteHandler, ReportHandler, Severity, SourceCode}; 2 | use nu_protocol::engine::StateWorkingSet; 3 | use thiserror::Error; 4 | 5 | /// This error exists so that we can defer SourceCode handling. It simply 6 | /// forwards most methods, except for `.source_code()`, which we provide. 7 | #[derive(Error)] 8 | #[error("{0}")] 9 | pub struct CliError<'src>( 10 | pub &'src (dyn miette::Diagnostic + Send + Sync + 'static), 11 | pub &'src StateWorkingSet<'src>, 12 | ); 13 | 14 | impl std::fmt::Debug for CliError<'_> { 15 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 16 | MietteHandler::default().debug(self, f)?; 17 | Ok(()) 18 | } 19 | } 20 | 21 | impl<'src> miette::Diagnostic for CliError<'src> { 22 | fn code<'a>(&'a self) -> Option> { 23 | self.0.code() 24 | } 25 | 26 | fn severity(&self) -> Option { 27 | self.0.severity() 28 | } 29 | 30 | fn help<'a>(&'a self) -> Option> { 31 | self.0.help() 32 | } 33 | 34 | fn url<'a>(&'a self) -> Option> { 35 | self.0.url() 36 | } 37 | 38 | fn labels<'a>(&'a self) -> Option + 'a>> { 39 | self.0.labels() 40 | } 41 | 42 | // Finally, we redirect the source_code method to our own source. 43 | fn source_code(&self) -> Option<&dyn SourceCode> { 44 | Some(&self.1) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /crates/nu-cli/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod completions; 2 | mod errors; 3 | mod nu_highlight; 4 | mod prompt; 5 | mod syntax_highlight; 6 | mod validation; 7 | 8 | pub use completions::NuCompleter; 9 | pub use errors::CliError; 10 | pub use nu_highlight::NuHighlight; 11 | pub use prompt::NushellPrompt; 12 | pub use syntax_highlight::NuHighlighter; 13 | pub use validation::NuValidator; 14 | -------------------------------------------------------------------------------- /crates/nu-cli/src/validation.rs: -------------------------------------------------------------------------------- 1 | use nu_parser::{parse, ParseError}; 2 | use nu_protocol::engine::{EngineState, StateWorkingSet}; 3 | use reedline::{ValidationResult, Validator}; 4 | 5 | pub struct NuValidator { 6 | pub engine_state: EngineState, 7 | } 8 | 9 | impl Validator for NuValidator { 10 | fn validate(&self, line: &str) -> ValidationResult { 11 | let mut working_set = StateWorkingSet::new(&self.engine_state); 12 | let (_, err) = parse(&mut working_set, None, line.as_bytes(), false); 13 | 14 | if matches!(err, Some(ParseError::UnexpectedEof(..))) { 15 | ValidationResult::Incomplete 16 | } else { 17 | ValidationResult::Complete 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/nu-color-config/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-color-config" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | nu-protocol = { path = "../nu-protocol" } 8 | # nu-ansi-term = { path = "../nu-ansi-term" } 9 | nu-ansi-term = "0.42.0" 10 | nu-json = { path = "../nu-json" } 11 | nu-table = { path = "../nu-table" } 12 | 13 | serde = { version="1.0.123", features=["derive"] } 14 | -------------------------------------------------------------------------------- /crates/nu-color-config/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod color_config; 2 | mod nu_style; 3 | mod shape_color; 4 | 5 | pub use color_config::*; 6 | pub use nu_style::*; 7 | pub use shape_color::*; 8 | -------------------------------------------------------------------------------- /crates/nu-command/assets/228_themes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/crates/nu-command/assets/228_themes.zip -------------------------------------------------------------------------------- /crates/nu-command/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> shadow_rs::SdResult<()> { 2 | shadow_rs::new() 3 | } 4 | -------------------------------------------------------------------------------- /crates/nu-command/src/conversions/into/command.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Into; 10 | 11 | impl Command for Into { 12 | fn name(&self) -> &str { 13 | "into" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("into").category(Category::Conversions) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Apply into function." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help(&Into.signature(), &[], engine_state, stack), 33 | span: call.head, 34 | } 35 | .into_pipeline_data()) 36 | } 37 | } 38 | 39 | #[cfg(test)] 40 | mod test { 41 | use super::*; 42 | 43 | #[test] 44 | fn test_examples() { 45 | use crate::test_examples; 46 | 47 | test_examples(Into {}) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /crates/nu-command/src/conversions/into/mod.rs: -------------------------------------------------------------------------------- 1 | mod binary; 2 | mod bool; 3 | mod command; 4 | mod datetime; 5 | mod decimal; 6 | mod filesize; 7 | mod int; 8 | mod string; 9 | 10 | pub use self::bool::SubCommand as IntoBool; 11 | pub use self::filesize::SubCommand as IntoFilesize; 12 | pub use binary::SubCommand as IntoBinary; 13 | pub use command::Into; 14 | pub use datetime::SubCommand as IntoDatetime; 15 | pub use decimal::SubCommand as IntoDecimal; 16 | pub use int::SubCommand as IntoInt; 17 | pub use string::SubCommand as IntoString; 18 | -------------------------------------------------------------------------------- /crates/nu-command/src/conversions/mod.rs: -------------------------------------------------------------------------------- 1 | mod fmt; 2 | pub(crate) mod into; 3 | 4 | pub use fmt::Fmt; 5 | pub use into::*; 6 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/alias.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct Alias; 7 | 8 | impl Command for Alias { 9 | fn name(&self) -> &str { 10 | "alias" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Alias a command (with optional flags) to a new name" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("alias") 19 | .required("name", SyntaxShape::String, "name of the alias") 20 | .required( 21 | "initial_value", 22 | SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)), 23 | "equals sign followed by value", 24 | ) 25 | .category(Category::Core) 26 | } 27 | 28 | fn run( 29 | &self, 30 | _engine_state: &EngineState, 31 | _stack: &mut Stack, 32 | call: &Call, 33 | _input: PipelineData, 34 | ) -> Result { 35 | Ok(PipelineData::new(call.head)) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/def.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct Def; 7 | 8 | impl Command for Def { 9 | fn name(&self) -> &str { 10 | "def" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Define a custom command" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("def") 19 | .required("def_name", SyntaxShape::String, "definition name") 20 | .required("params", SyntaxShape::Signature, "parameters") 21 | .required( 22 | "block", 23 | SyntaxShape::Block(Some(vec![])), 24 | "body of the definition", 25 | ) 26 | .category(Category::Core) 27 | } 28 | 29 | fn run( 30 | &self, 31 | _engine_state: &EngineState, 32 | _stack: &mut Stack, 33 | call: &Call, 34 | _input: PipelineData, 35 | ) -> Result { 36 | Ok(PipelineData::new(call.head)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/def_env.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct DefEnv; 7 | 8 | impl Command for DefEnv { 9 | fn name(&self) -> &str { 10 | "def-env" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Define a custom command, which participates in the caller environment" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("def-env") 19 | .required("def_name", SyntaxShape::String, "definition name") 20 | .required("params", SyntaxShape::Signature, "parameters") 21 | .required( 22 | "block", 23 | SyntaxShape::Block(Some(vec![])), 24 | "body of the definition", 25 | ) 26 | .category(Category::Core) 27 | } 28 | 29 | fn run( 30 | &self, 31 | _engine_state: &EngineState, 32 | _stack: &mut Stack, 33 | call: &Call, 34 | _input: PipelineData, 35 | ) -> Result { 36 | Ok(PipelineData::new(call.head)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/export.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct ExportCommand; 10 | 11 | impl Command for ExportCommand { 12 | fn name(&self) -> &str { 13 | "export" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("export").category(Category::Core) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Export custom commands or environment variables from a module." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &ExportCommand.signature(), 34 | &ExportCommand.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/export_def.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct ExportDef; 7 | 8 | impl Command for ExportDef { 9 | fn name(&self) -> &str { 10 | "export def" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Define a custom command and export it from a module" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("export def") 19 | .required("name", SyntaxShape::String, "definition name") 20 | .required("params", SyntaxShape::Signature, "parameters") 21 | .required( 22 | "block", 23 | SyntaxShape::Block(Some(vec![])), 24 | "body of the definition", 25 | ) 26 | .category(Category::Core) 27 | } 28 | 29 | fn run( 30 | &self, 31 | _engine_state: &EngineState, 32 | _stack: &mut Stack, 33 | call: &Call, 34 | _input: PipelineData, 35 | ) -> Result { 36 | Ok(PipelineData::new(call.head)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/export_def_env.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct ExportDefEnv; 7 | 8 | impl Command for ExportDefEnv { 9 | fn name(&self) -> &str { 10 | "export def-env" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Define a custom command that participates in the environment and export it from a module" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("export def-env") 19 | .required("name", SyntaxShape::String, "definition name") 20 | .required("params", SyntaxShape::Signature, "parameters") 21 | .required( 22 | "block", 23 | SyntaxShape::Block(Some(vec![])), 24 | "body of the definition", 25 | ) 26 | .category(Category::Core) 27 | } 28 | 29 | fn run( 30 | &self, 31 | _engine_state: &EngineState, 32 | _stack: &mut Stack, 33 | call: &Call, 34 | _input: PipelineData, 35 | ) -> Result { 36 | Ok(PipelineData::new(call.head)) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/export_env.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct ExportEnv; 7 | 8 | impl Command for ExportEnv { 9 | fn name(&self) -> &str { 10 | "export env" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Export a block from a module that will be evaluated as an environment variable when imported." 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("export env") 19 | .required( 20 | "name", 21 | SyntaxShape::String, 22 | "name of the environment variable", 23 | ) 24 | .required( 25 | "block", 26 | SyntaxShape::Block(Some(vec![])), 27 | "body of the environment variable definition", 28 | ) 29 | .category(Category::Core) 30 | } 31 | 32 | fn run( 33 | &self, 34 | _engine_state: &EngineState, 35 | _stack: &mut Stack, 36 | call: &Call, 37 | _input: PipelineData, 38 | ) -> Result { 39 | //TODO: Add the env to stack 40 | Ok(PipelineData::new(call.head)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/ignore.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, Example, PipelineData, Signature}; 4 | 5 | #[derive(Clone)] 6 | pub struct Ignore; 7 | 8 | impl Command for Ignore { 9 | fn name(&self) -> &str { 10 | "ignore" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Ignore the output of the previous command in the pipeline" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("ignore").category(Category::Core) 19 | } 20 | 21 | fn run( 22 | &self, 23 | _engine_state: &EngineState, 24 | _stack: &mut Stack, 25 | call: &Call, 26 | _input: PipelineData, 27 | ) -> Result { 28 | Ok(PipelineData::new(call.head)) 29 | } 30 | 31 | fn examples(&self) -> Vec { 32 | vec![Example { 33 | description: "Ignore the output of an echo command", 34 | example: "echo done | ignore", 35 | result: None, 36 | }] 37 | } 38 | } 39 | 40 | #[cfg(test)] 41 | mod test { 42 | #[test] 43 | fn test_examples() { 44 | use super::Ignore; 45 | use crate::test_examples; 46 | test_examples(Ignore {}) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/mod.rs: -------------------------------------------------------------------------------- 1 | mod alias; 2 | mod debug; 3 | mod def; 4 | mod def_env; 5 | mod describe; 6 | mod do_; 7 | mod echo; 8 | mod error_make; 9 | mod export; 10 | mod export_def; 11 | mod export_def_env; 12 | mod export_env; 13 | mod for_; 14 | mod help; 15 | mod hide; 16 | mod history; 17 | mod if_; 18 | mod ignore; 19 | mod let_; 20 | mod metadata; 21 | mod module; 22 | mod source; 23 | mod tutor; 24 | mod use_; 25 | mod version; 26 | 27 | pub use alias::Alias; 28 | pub use debug::Debug; 29 | pub use def::Def; 30 | pub use def_env::DefEnv; 31 | pub use describe::Describe; 32 | pub use do_::Do; 33 | pub use echo::Echo; 34 | pub use error_make::ErrorMake; 35 | pub use export::ExportCommand; 36 | pub use export_def::ExportDef; 37 | pub use export_def_env::ExportDefEnv; 38 | pub use export_env::ExportEnv; 39 | pub use for_::For; 40 | pub use help::Help; 41 | pub use hide::Hide; 42 | pub use history::History; 43 | pub use if_::If; 44 | pub use ignore::Ignore; 45 | pub use let_::Let; 46 | pub use metadata::Metadata; 47 | pub use module::Module; 48 | pub use source::Source; 49 | pub use tutor::Tutor; 50 | pub use use_::Use; 51 | pub use version::Version; 52 | #[cfg(feature = "plugin")] 53 | mod register; 54 | 55 | #[cfg(feature = "plugin")] 56 | pub use register::Register; 57 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/module.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, Signature, SyntaxShape}; 4 | 5 | #[derive(Clone)] 6 | pub struct Module; 7 | 8 | impl Command for Module { 9 | fn name(&self) -> &str { 10 | "module" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Define a custom module" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("module") 19 | .required("module_name", SyntaxShape::String, "module name") 20 | .required( 21 | "block", 22 | SyntaxShape::Block(Some(vec![])), 23 | "body of the module", 24 | ) 25 | .category(Category::Core) 26 | } 27 | 28 | fn run( 29 | &self, 30 | _engine_state: &EngineState, 31 | _stack: &mut Stack, 32 | call: &Call, 33 | _input: PipelineData, 34 | ) -> Result { 35 | Ok(PipelineData::new(call.head)) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crates/nu-command/src/core_commands/source.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::{eval_block, CallExt}; 2 | use nu_protocol::ast::Call; 3 | use nu_protocol::engine::{Command, EngineState, Stack}; 4 | use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape}; 5 | 6 | /// Source a file for environment variables. 7 | #[derive(Clone)] 8 | pub struct Source; 9 | 10 | impl Command for Source { 11 | fn name(&self) -> &str { 12 | "source" 13 | } 14 | 15 | fn signature(&self) -> Signature { 16 | Signature::build("source") 17 | .required( 18 | "filename", 19 | SyntaxShape::Filepath, 20 | "the filepath to the script file to source", 21 | ) 22 | .category(Category::Core) 23 | } 24 | 25 | fn usage(&self) -> &str { 26 | "Runs a script file in the current context." 27 | } 28 | 29 | fn run( 30 | &self, 31 | engine_state: &EngineState, 32 | stack: &mut Stack, 33 | call: &Call, 34 | input: PipelineData, 35 | ) -> Result { 36 | // Note: this hidden positional is the block_id that corresponded to the 0th position 37 | // it is put here by the parser 38 | let block_id: i64 = call.req(engine_state, stack, 1)?; 39 | 40 | let block = engine_state.get_block(block_id as usize).clone(); 41 | eval_block(engine_state, stack, &block, input) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/README.md: -------------------------------------------------------------------------------- 1 | # nu-dataframe 2 | 3 | The nu-dataframe crate holds the definitions of the dataframe structures and commands 4 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/eager/command.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, ShellError, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Dataframe; 10 | 11 | impl Command for Dataframe { 12 | fn name(&self) -> &str { 13 | "dfr" 14 | } 15 | 16 | fn usage(&self) -> &str { 17 | "Dataframe commands" 18 | } 19 | 20 | fn signature(&self) -> Signature { 21 | Signature::build(self.name()).category(Category::Custom("dataframe".into())) 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &Dataframe.signature(), 34 | &Dataframe.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/mod.rs: -------------------------------------------------------------------------------- 1 | mod eager; 2 | mod series; 3 | mod values; 4 | 5 | pub use eager::add_eager_decls; 6 | pub use series::add_series_decls; 7 | 8 | use nu_protocol::engine::StateWorkingSet; 9 | 10 | pub fn add_dataframe_decls(working_set: &mut StateWorkingSet) { 11 | add_series_decls(working_set); 12 | add_eager_decls(working_set); 13 | } 14 | 15 | #[cfg(test)] 16 | mod test_dataframe; 17 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/series/date/mod.rs: -------------------------------------------------------------------------------- 1 | mod get_day; 2 | mod get_hour; 3 | mod get_minute; 4 | mod get_month; 5 | mod get_nanosecond; 6 | mod get_ordinal; 7 | mod get_second; 8 | mod get_week; 9 | mod get_weekday; 10 | mod get_year; 11 | 12 | pub use get_day::GetDay; 13 | pub use get_hour::GetHour; 14 | pub use get_minute::GetMinute; 15 | pub use get_month::GetMonth; 16 | pub use get_nanosecond::GetNanosecond; 17 | pub use get_ordinal::GetOrdinal; 18 | pub use get_second::GetSecond; 19 | pub use get_week::GetWeek; 20 | pub use get_weekday::GetWeekDay; 21 | pub use get_year::GetYear; 22 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/series/indexes/mod.rs: -------------------------------------------------------------------------------- 1 | mod arg_sort; 2 | mod arg_true; 3 | mod arg_unique; 4 | mod set_with_idx; 5 | 6 | pub use arg_sort::ArgSort; 7 | pub use arg_true::ArgTrue; 8 | pub use arg_unique::ArgUnique; 9 | pub use set_with_idx::SetWithIndex; 10 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/series/masks/mod.rs: -------------------------------------------------------------------------------- 1 | mod is_duplicated; 2 | mod is_in; 3 | mod is_not_null; 4 | mod is_null; 5 | mod is_unique; 6 | mod not; 7 | mod set; 8 | 9 | pub use is_duplicated::IsDuplicated; 10 | pub use is_in::IsIn; 11 | pub use is_not_null::IsNotNull; 12 | pub use is_null::IsNull; 13 | pub use is_unique::IsUnique; 14 | pub use not::NotSeries; 15 | pub use set::SetSeries; 16 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/series/string/mod.rs: -------------------------------------------------------------------------------- 1 | mod concatenate; 2 | mod contains; 3 | mod replace; 4 | mod replace_all; 5 | mod str_lengths; 6 | mod str_slice; 7 | mod strftime; 8 | mod to_lowercase; 9 | mod to_uppercase; 10 | 11 | pub use concatenate::Concatenate; 12 | pub use contains::Contains; 13 | pub use replace::Replace; 14 | pub use replace_all::ReplaceAll; 15 | pub use str_lengths::StrLengths; 16 | pub use str_slice::StrSlice; 17 | pub use strftime::StrFTime; 18 | pub use to_lowercase::ToLowerCase; 19 | pub use to_uppercase::ToUpperCase; 20 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/values/mod.rs: -------------------------------------------------------------------------------- 1 | mod nu_dataframe; 2 | mod nu_groupby; 3 | pub mod utils; 4 | 5 | pub use nu_dataframe::{Axis, Column, NuDataFrame}; 6 | pub use nu_groupby::NuGroupBy; 7 | -------------------------------------------------------------------------------- /crates/nu-command/src/dataframe/values/nu_groupby/custom_value.rs: -------------------------------------------------------------------------------- 1 | use super::NuGroupBy; 2 | use nu_protocol::{CustomValue, ShellError, Span, Value}; 3 | 4 | // CustomValue implementation for NuDataFrame 5 | impl CustomValue for NuGroupBy { 6 | fn typetag_name(&self) -> &'static str { 7 | "groupby" 8 | } 9 | 10 | fn typetag_deserialize(&self) { 11 | unimplemented!("typetag_deserialize") 12 | } 13 | 14 | fn clone_value(&self, span: nu_protocol::Span) -> Value { 15 | let cloned = NuGroupBy { 16 | dataframe: self.dataframe.clone(), 17 | by: self.by.clone(), 18 | groups: self.groups.clone(), 19 | }; 20 | 21 | Value::CustomValue { 22 | val: Box::new(cloned), 23 | span, 24 | } 25 | } 26 | 27 | fn value_string(&self) -> String { 28 | self.typetag_name().to_string() 29 | } 30 | 31 | fn to_base_value(&self, span: Span) -> Result { 32 | let vals = self.print(span)?; 33 | 34 | Ok(Value::List { vals, span }) 35 | } 36 | 37 | fn to_json(&self) -> nu_json::Value { 38 | nu_json::Value::Null 39 | } 40 | 41 | fn as_any(&self) -> &dyn std::any::Any { 42 | self 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /crates/nu-command/src/date/date_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, ShellError, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Date; 10 | 11 | impl Command for Date { 12 | fn name(&self) -> &str { 13 | "date" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("date").category(Category::Date) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "date" 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | date(engine_state, stack, call) 32 | } 33 | } 34 | 35 | fn date( 36 | engine_state: &EngineState, 37 | stack: &mut Stack, 38 | call: &Call, 39 | ) -> Result { 40 | let head = call.head; 41 | 42 | Ok(Value::String { 43 | val: get_full_help(&Date.signature(), &Date.examples(), engine_state, stack), 44 | span: head, 45 | } 46 | .into_pipeline_data()) 47 | } 48 | -------------------------------------------------------------------------------- /crates/nu-command/src/date/list_timezone.rs: -------------------------------------------------------------------------------- 1 | use chrono_tz::TZ_VARIANTS; 2 | use nu_protocol::ast::Call; 3 | use nu_protocol::engine::{Command, EngineState, Stack}; 4 | use nu_protocol::{Category, IntoInterruptiblePipelineData, PipelineData, Signature, Value}; 5 | 6 | #[derive(Clone)] 7 | pub struct SubCommand; 8 | 9 | impl Command for SubCommand { 10 | fn name(&self) -> &str { 11 | "date list-timezone" 12 | } 13 | 14 | fn signature(&self) -> Signature { 15 | Signature::build("date list-timezone").category(Category::Date) 16 | } 17 | 18 | fn usage(&self) -> &str { 19 | "List supported time zones." 20 | } 21 | 22 | fn run( 23 | &self, 24 | engine_state: &EngineState, 25 | _stack: &mut Stack, 26 | call: &Call, 27 | _input: PipelineData, 28 | ) -> Result { 29 | let span = call.head; 30 | 31 | Ok(TZ_VARIANTS 32 | .iter() 33 | .map(move |x| { 34 | let cols = vec!["timezone".into()]; 35 | let vals = vec![Value::String { 36 | val: x.name().to_string(), 37 | span, 38 | }]; 39 | Value::Record { cols, vals, span } 40 | }) 41 | .into_iter() 42 | .into_pipeline_data(engine_state.ctrlc.clone())) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /crates/nu-command/src/date/mod.rs: -------------------------------------------------------------------------------- 1 | mod date_; 2 | mod format; 3 | mod humanize; 4 | mod list_timezone; 5 | mod now; 6 | mod parser; 7 | mod to_table; 8 | mod to_timezone; 9 | mod utils; 10 | 11 | pub use date_::Date; 12 | pub use format::SubCommand as DateFormat; 13 | pub use humanize::SubCommand as DateHumanize; 14 | pub use list_timezone::SubCommand as DateListTimezones; 15 | pub use now::SubCommand as DateNow; 16 | pub use to_table::SubCommand as DateToTable; 17 | pub use to_timezone::SubCommand as DateToTimezone; 18 | -------------------------------------------------------------------------------- /crates/nu-command/src/date/now.rs: -------------------------------------------------------------------------------- 1 | use chrono::Local; 2 | use nu_protocol::ast::Call; 3 | use nu_protocol::engine::{Command, EngineState, Stack}; 4 | use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, Value}; 5 | #[derive(Clone)] 6 | pub struct SubCommand; 7 | 8 | impl Command for SubCommand { 9 | fn name(&self) -> &str { 10 | "date now" 11 | } 12 | 13 | fn signature(&self) -> Signature { 14 | Signature::build("date now").category(Category::Date) 15 | } 16 | 17 | fn usage(&self) -> &str { 18 | "Get the current date." 19 | } 20 | 21 | fn run( 22 | &self, 23 | _engine_state: &EngineState, 24 | _stack: &mut Stack, 25 | call: &Call, 26 | _input: PipelineData, 27 | ) -> Result { 28 | let head = call.head; 29 | let dt = Local::now(); 30 | Ok(Value::Date { 31 | val: dt.with_timezone(dt.offset()), 32 | span: head, 33 | } 34 | .into_pipeline_data()) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /crates/nu-command/src/env/mod.rs: -------------------------------------------------------------------------------- 1 | mod env_command; 2 | mod let_env; 3 | mod load_env; 4 | mod with_env; 5 | 6 | pub use env_command::Env; 7 | pub use let_env::LetEnv; 8 | pub use load_env::LoadEnv; 9 | pub use with_env::WithEnv; 10 | -------------------------------------------------------------------------------- /crates/nu-command/src/experimental/mod.rs: -------------------------------------------------------------------------------- 1 | mod git; 2 | mod git_checkout; 3 | mod list_git_branches; 4 | mod view_source; 5 | 6 | pub use git::Git; 7 | pub use git_checkout::GitCheckout; 8 | pub use list_git_branches::ListGitBranches; 9 | pub use view_source::ViewSource; 10 | -------------------------------------------------------------------------------- /crates/nu-command/src/filesystem/mod.rs: -------------------------------------------------------------------------------- 1 | mod cd; 2 | mod cp; 3 | mod ls; 4 | mod mkdir; 5 | mod mv; 6 | mod open; 7 | mod rm; 8 | mod save; 9 | mod touch; 10 | mod util; 11 | 12 | pub use cd::Cd; 13 | pub use cp::Cp; 14 | pub use ls::Ls; 15 | pub use mkdir::Mkdir; 16 | pub use mv::Mv; 17 | pub use open::{BufferedReader, Open}; 18 | pub use rm::Rm; 19 | pub use save::Save; 20 | pub use touch::Touch; 21 | -------------------------------------------------------------------------------- /crates/nu-command/src/filters/drop/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod column; 2 | pub mod drop_; 3 | pub mod nth; 4 | 5 | pub use column::DropColumn; 6 | pub use drop_::Drop; 7 | pub use nth::DropNth; 8 | -------------------------------------------------------------------------------- /crates/nu-command/src/filters/keep/mod.rs: -------------------------------------------------------------------------------- 1 | mod keep_; 2 | mod keep_until; 3 | mod keep_while; 4 | 5 | pub use keep_::Keep; 6 | pub use keep_until::KeepUntil; 7 | pub use keep_while::KeepWhile; 8 | -------------------------------------------------------------------------------- /crates/nu-command/src/filters/shuffle.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature}; 4 | use rand::prelude::SliceRandom; 5 | use rand::thread_rng; 6 | 7 | #[derive(Clone)] 8 | pub struct Shuffle; 9 | 10 | impl Command for Shuffle { 11 | fn name(&self) -> &str { 12 | "shuffle" 13 | } 14 | 15 | fn signature(&self) -> nu_protocol::Signature { 16 | Signature::build("shuffle").category(Category::Filters) 17 | } 18 | 19 | fn usage(&self) -> &str { 20 | "Shuffle rows randomly." 21 | } 22 | 23 | fn run( 24 | &self, 25 | engine_state: &EngineState, 26 | _stack: &mut Stack, 27 | _call: &Call, 28 | input: PipelineData, 29 | ) -> Result { 30 | let mut v: Vec<_> = input.into_iter().collect(); 31 | v.shuffle(&mut thread_rng()); 32 | let iter = v.into_iter(); 33 | Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /crates/nu-command/src/filters/skip/mod.rs: -------------------------------------------------------------------------------- 1 | mod skip_; 2 | mod skip_until; 3 | mod skip_while; 4 | 5 | pub use skip_::Skip; 6 | pub use skip_until::SkipUntil; 7 | pub use skip_while::SkipWhile; 8 | -------------------------------------------------------------------------------- /crates/nu-command/src/formats/from/command.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, ShellError, Signature}; 4 | 5 | #[derive(Clone)] 6 | pub struct From; 7 | 8 | impl Command for From { 9 | fn name(&self) -> &str { 10 | "from" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Parse a string or binary data into structured data" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("from").category(Category::Formats) 19 | } 20 | 21 | fn run( 22 | &self, 23 | _engine_state: &EngineState, 24 | _stack: &mut Stack, 25 | call: &Call, 26 | _input: PipelineData, 27 | ) -> Result { 28 | Ok(PipelineData::new(call.head)) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /crates/nu-command/src/formats/from/mod.rs: -------------------------------------------------------------------------------- 1 | mod command; 2 | mod csv; 3 | mod delimited; 4 | mod eml; 5 | mod ics; 6 | mod ini; 7 | mod json; 8 | mod ods; 9 | mod ssv; 10 | mod toml; 11 | mod tsv; 12 | mod url; 13 | mod vcf; 14 | mod xlsx; 15 | mod xml; 16 | mod yaml; 17 | 18 | pub use self::csv::FromCsv; 19 | pub use self::toml::FromToml; 20 | pub use self::url::FromUrl; 21 | pub use command::From; 22 | pub use eml::FromEml; 23 | pub use ics::FromIcs; 24 | pub use ini::FromIni; 25 | pub use json::FromJson; 26 | pub use ods::FromOds; 27 | pub use ssv::FromSsv; 28 | pub use tsv::FromTsv; 29 | pub use vcf::FromVcf; 30 | pub use xlsx::FromXlsx; 31 | pub use xml::FromXml; 32 | pub use yaml::FromYaml; 33 | pub use yaml::FromYml; 34 | -------------------------------------------------------------------------------- /crates/nu-command/src/formats/mod.rs: -------------------------------------------------------------------------------- 1 | mod from; 2 | mod to; 3 | 4 | pub use from::*; 5 | pub use to::*; 6 | -------------------------------------------------------------------------------- /crates/nu-command/src/formats/to/command.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{Category, PipelineData, ShellError, Signature}; 4 | 5 | #[derive(Clone)] 6 | pub struct To; 7 | 8 | impl Command for To { 9 | fn name(&self) -> &str { 10 | "to" 11 | } 12 | 13 | fn usage(&self) -> &str { 14 | "Translate structured data to a format" 15 | } 16 | 17 | fn signature(&self) -> nu_protocol::Signature { 18 | Signature::build("to").category(Category::Formats) 19 | } 20 | 21 | fn run( 22 | &self, 23 | _engine_state: &EngineState, 24 | _stack: &mut Stack, 25 | call: &Call, 26 | _input: PipelineData, 27 | ) -> Result { 28 | Ok(PipelineData::new(call.head)) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /crates/nu-command/src/formats/to/mod.rs: -------------------------------------------------------------------------------- 1 | mod command; 2 | mod csv; 3 | mod delimited; 4 | mod html; 5 | mod json; 6 | mod md; 7 | mod toml; 8 | mod tsv; 9 | mod url; 10 | mod xml; 11 | mod yaml; 12 | 13 | pub use self::csv::ToCsv; 14 | pub use self::toml::ToToml; 15 | pub use self::url::ToUrl; 16 | pub use command::To; 17 | pub use html::ToHtml; 18 | pub use json::ToJson; 19 | pub use md::ToMd; 20 | pub use tsv::ToTsv; 21 | pub use xml::ToXml; 22 | pub use yaml::ToYaml; 23 | -------------------------------------------------------------------------------- /crates/nu-command/src/generators/mod.rs: -------------------------------------------------------------------------------- 1 | mod cal; 2 | mod seq; 3 | mod seq_date; 4 | 5 | pub use cal::Cal; 6 | pub use seq::Seq; 7 | pub use seq_date::SeqDate; 8 | -------------------------------------------------------------------------------- /crates/nu-command/src/hash/hash_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::ast::Call; 3 | use nu_protocol::engine::{Command, EngineState, Stack}; 4 | use nu_protocol::{Category, IntoPipelineData, PipelineData, ShellError, Signature, Value}; 5 | 6 | #[derive(Clone)] 7 | pub struct Hash; 8 | 9 | impl Command for Hash { 10 | fn name(&self) -> &str { 11 | "hash" 12 | } 13 | 14 | fn signature(&self) -> Signature { 15 | Signature::build("hash").category(Category::Hash) 16 | } 17 | 18 | fn usage(&self) -> &str { 19 | "Apply hash function." 20 | } 21 | 22 | fn run( 23 | &self, 24 | engine_state: &EngineState, 25 | stack: &mut Stack, 26 | call: &Call, 27 | _input: PipelineData, 28 | ) -> Result { 29 | Ok(Value::String { 30 | val: get_full_help(&Self.signature(), &Self.examples(), engine_state, stack), 31 | span: call.head, 32 | } 33 | .into_pipeline_data()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /crates/nu-command/src/hash/mod.rs: -------------------------------------------------------------------------------- 1 | mod base64; 2 | mod generic_digest; 3 | mod hash_; 4 | mod md5; 5 | mod sha256; 6 | 7 | pub use self::base64::Base64; 8 | pub use self::hash_::Hash; 9 | pub use self::md5::HashMd5; 10 | pub use self::sha256::HashSha256; 11 | -------------------------------------------------------------------------------- /crates/nu-command/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod conversions; 2 | mod core_commands; 3 | mod date; 4 | mod default_context; 5 | mod env; 6 | mod example_test; 7 | mod experimental; 8 | mod filesystem; 9 | mod filters; 10 | mod formats; 11 | mod generators; 12 | mod hash; 13 | mod math; 14 | mod network; 15 | mod path; 16 | mod platform; 17 | mod random; 18 | mod shells; 19 | mod strings; 20 | mod system; 21 | mod viewers; 22 | 23 | pub use conversions::*; 24 | pub use core_commands::*; 25 | pub use date::*; 26 | pub use default_context::*; 27 | pub use env::*; 28 | #[cfg(test)] 29 | pub use example_test::test_examples; 30 | pub use experimental::*; 31 | pub use filesystem::*; 32 | pub use filters::*; 33 | pub use formats::*; 34 | pub use generators::*; 35 | pub use hash::*; 36 | pub use math::*; 37 | pub use network::*; 38 | pub use path::*; 39 | pub use platform::*; 40 | pub use random::*; 41 | pub use shells::*; 42 | pub use strings::*; 43 | pub use system::*; 44 | pub use viewers::*; 45 | 46 | #[cfg(feature = "dataframe")] 47 | mod dataframe; 48 | 49 | #[cfg(feature = "dataframe")] 50 | pub use dataframe::*; 51 | -------------------------------------------------------------------------------- /crates/nu-command/src/math/math_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct MathCommand; 10 | 11 | impl Command for MathCommand { 12 | fn name(&self) -> &str { 13 | "math" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("math").category(Category::Math) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Use mathematical functions as aggregate functions on a list of numbers or tables." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &MathCommand.signature(), 34 | &MathCommand.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/math/mod.rs: -------------------------------------------------------------------------------- 1 | mod abs; 2 | mod avg; 3 | mod ceil; 4 | mod eval; 5 | mod floor; 6 | pub mod math_; 7 | mod max; 8 | mod median; 9 | mod min; 10 | mod mode; 11 | mod product; 12 | mod reducers; 13 | mod round; 14 | mod sqrt; 15 | mod stddev; 16 | mod sum; 17 | mod utils; 18 | mod variance; 19 | 20 | pub use abs::SubCommand as MathAbs; 21 | pub use avg::SubCommand as MathAvg; 22 | pub use ceil::SubCommand as MathCeil; 23 | pub use eval::SubCommand as MathEval; 24 | pub use floor::SubCommand as MathFloor; 25 | pub use math_::MathCommand as Math; 26 | pub use max::SubCommand as MathMax; 27 | pub use median::SubCommand as MathMedian; 28 | pub use min::SubCommand as MathMin; 29 | pub use mode::SubCommand as MathMode; 30 | pub use product::SubCommand as MathProduct; 31 | pub use round::SubCommand as MathRound; 32 | pub use sqrt::SubCommand as MathSqrt; 33 | pub use stddev::SubCommand as MathStddev; 34 | pub use sum::SubCommand as MathSum; 35 | pub use variance::SubCommand as MathVariance; 36 | -------------------------------------------------------------------------------- /crates/nu-command/src/network/mod.rs: -------------------------------------------------------------------------------- 1 | mod fetch; 2 | mod url; 3 | 4 | pub use self::url::*; 5 | pub use fetch::SubCommand as Fetch; 6 | -------------------------------------------------------------------------------- /crates/nu-command/src/network/url/url_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Url; 10 | 11 | impl Command for Url { 12 | fn name(&self) -> &str { 13 | "url" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("url").category(Category::Network) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Apply url function." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help(&Url.signature(), &Url.examples(), engine_state, stack), 33 | span: call.head, 34 | } 35 | .into_pipeline_data()) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crates/nu-command/src/platform/ansi/mod.rs: -------------------------------------------------------------------------------- 1 | mod ansi_; 2 | mod gradient; 3 | mod strip; 4 | 5 | pub use ansi_::AnsiCommand as Ansi; 6 | pub use gradient::SubCommand as AnsiGradient; 7 | pub use strip::SubCommand as AnsiStrip; 8 | -------------------------------------------------------------------------------- /crates/nu-command/src/platform/clear.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::ast::Call; 2 | use nu_protocol::engine::{Command, EngineState, Stack}; 3 | use nu_protocol::{ 4 | Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Value, 5 | }; 6 | use std::process::Command as CommandSys; 7 | 8 | #[derive(Clone)] 9 | pub struct Clear; 10 | 11 | impl Command for Clear { 12 | fn name(&self) -> &str { 13 | "clear" 14 | } 15 | 16 | fn usage(&self) -> &str { 17 | "Clear the terminal." 18 | } 19 | 20 | fn signature(&self) -> Signature { 21 | Signature::build("clear").category(Category::Platform) 22 | } 23 | 24 | fn run( 25 | &self, 26 | _engine_state: &EngineState, 27 | _stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | if cfg!(windows) { 32 | CommandSys::new("cmd") 33 | .args(["/C", "cls"]) 34 | .status() 35 | .expect("failed to execute process"); 36 | } else if cfg!(unix) { 37 | CommandSys::new("/bin/sh") 38 | .args(["-c", "clear"]) 39 | .status() 40 | .expect("failed to execute process"); 41 | } 42 | 43 | Ok(Value::Nothing { span: call.head }.into_pipeline_data()) 44 | } 45 | 46 | fn examples(&self) -> Vec { 47 | vec![Example { 48 | description: "Clear the terminal", 49 | example: "clear", 50 | result: None, 51 | }] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /crates/nu-command/src/platform/mod.rs: -------------------------------------------------------------------------------- 1 | mod ansi; 2 | mod clear; 3 | mod dir_info; 4 | mod du; 5 | mod input; 6 | mod kill; 7 | mod reedline_commands; 8 | mod sleep; 9 | mod term_size; 10 | 11 | pub use ansi::{Ansi, AnsiGradient, AnsiStrip}; 12 | pub use clear::Clear; 13 | pub use dir_info::{DirBuilder, DirInfo, FileInfo}; 14 | pub use du::Du; 15 | pub use input::Input; 16 | pub use kill::Kill; 17 | pub use reedline_commands::{Keybindings, KeybindingsDefault, KeybindingsList, KeybindingsListen}; 18 | pub use sleep::Sleep; 19 | pub use term_size::TermSize; 20 | -------------------------------------------------------------------------------- /crates/nu-command/src/platform/reedline_commands/keybindings.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Keybindings; 10 | 11 | impl Command for Keybindings { 12 | fn name(&self) -> &str { 13 | "keybindings" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build(self.name()).category(Category::Platform) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Keybindings related commands" 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &Keybindings.signature(), 34 | &Keybindings.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/platform/reedline_commands/mod.rs: -------------------------------------------------------------------------------- 1 | mod keybindings; 2 | mod keybindings_default; 3 | mod keybindings_list; 4 | mod keybindings_listen; 5 | 6 | pub use keybindings::Keybindings; 7 | pub use keybindings_default::KeybindingsDefault; 8 | pub use keybindings_list::KeybindingsList; 9 | pub use keybindings_listen::KeybindingsListen; 10 | -------------------------------------------------------------------------------- /crates/nu-command/src/random/mod.rs: -------------------------------------------------------------------------------- 1 | mod bool; 2 | mod chars; 3 | mod decimal; 4 | mod dice; 5 | mod integer; 6 | mod random_; 7 | mod uuid; 8 | 9 | pub use self::bool::SubCommand as RandomBool; 10 | pub use self::chars::SubCommand as RandomChars; 11 | pub use self::decimal::SubCommand as RandomDecimal; 12 | pub use self::dice::SubCommand as RandomDice; 13 | pub use self::integer::SubCommand as RandomInteger; 14 | pub use self::uuid::SubCommand as RandomUuid; 15 | pub use random_::RandomCommand as Random; 16 | -------------------------------------------------------------------------------- /crates/nu-command/src/random/random_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct RandomCommand; 10 | 11 | impl Command for RandomCommand { 12 | fn name(&self) -> &str { 13 | "random" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("random").category(Category::Random) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Generate a random values." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &RandomCommand.signature(), 34 | &RandomCommand.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /crates/nu-command/src/shells/mod.rs: -------------------------------------------------------------------------------- 1 | mod enter; 2 | mod exit; 3 | mod g; 4 | mod n; 5 | mod p; 6 | mod shells_; 7 | 8 | pub use enter::Enter; 9 | pub use exit::Exit; 10 | pub use g::GotoShell; 11 | pub use n::NextShell; 12 | pub use p::PrevShell; 13 | pub use shells_::Shells; 14 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/format/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod command; 2 | 3 | pub use command::Format; 4 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/mod.rs: -------------------------------------------------------------------------------- 1 | mod build_string; 2 | mod char_; 3 | mod decode; 4 | mod detect_columns; 5 | mod format; 6 | mod parse; 7 | mod size; 8 | mod split; 9 | mod str_; 10 | 11 | pub use build_string::BuildString; 12 | pub use char_::Char; 13 | pub use decode::*; 14 | pub use detect_columns::*; 15 | pub use format::*; 16 | pub use parse::*; 17 | pub use size::Size; 18 | pub use split::*; 19 | pub use str_::*; 20 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/split/command.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct SplitCommand; 10 | 11 | impl Command for SplitCommand { 12 | fn name(&self) -> &str { 13 | "split" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("split").category(Category::Strings) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Split contents across desired subcommand (like row, column) via the separator." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help( 33 | &SplitCommand.signature(), 34 | &SplitCommand.examples(), 35 | engine_state, 36 | stack, 37 | ), 38 | span: call.head, 39 | } 40 | .into_pipeline_data()) 41 | } 42 | } 43 | 44 | // #[cfg(test)] 45 | // mod tests { 46 | // use super::Command; 47 | // use super::ShellError; 48 | 49 | // #[test] 50 | // fn examples_work_as_expected() -> Result<(), ShellError> { 51 | // use crate::examples::test as test_examples; 52 | 53 | // test_examples(Command {}) 54 | // } 55 | // } 56 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/split/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod chars; 2 | pub mod column; 3 | pub mod command; 4 | pub mod row; 5 | 6 | pub use chars::SubCommand as SplitChars; 7 | pub use column::SubCommand as SplitColumn; 8 | pub use command::SplitCommand as Split; 9 | pub use row::SubCommand as SplitRow; 10 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/str_/case/str_.rs: -------------------------------------------------------------------------------- 1 | use nu_engine::get_full_help; 2 | use nu_protocol::{ 3 | ast::Call, 4 | engine::{Command, EngineState, Stack}, 5 | Category, IntoPipelineData, PipelineData, Signature, Value, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct Str; 10 | 11 | impl Command for Str { 12 | fn name(&self) -> &str { 13 | "str" 14 | } 15 | 16 | fn signature(&self) -> Signature { 17 | Signature::build("str").category(Category::Strings) 18 | } 19 | 20 | fn usage(&self) -> &str { 21 | "Various commands for working with string data." 22 | } 23 | 24 | fn run( 25 | &self, 26 | engine_state: &EngineState, 27 | stack: &mut Stack, 28 | call: &Call, 29 | _input: PipelineData, 30 | ) -> Result { 31 | Ok(Value::String { 32 | val: get_full_help(&Str.signature(), &Str.examples(), engine_state, stack), 33 | span: call.head, 34 | } 35 | .into_pipeline_data()) 36 | } 37 | } 38 | 39 | #[cfg(test)] 40 | mod test { 41 | use crate::Str; 42 | 43 | #[test] 44 | fn test_examples() { 45 | use crate::test_examples; 46 | 47 | test_examples(Str {}) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/str_/mod.rs: -------------------------------------------------------------------------------- 1 | mod capitalize; 2 | mod case; 3 | mod collect; 4 | mod contains; 5 | mod downcase; 6 | mod ends_with; 7 | mod find_replace; 8 | mod index_of; 9 | mod length; 10 | mod lpad; 11 | mod reverse; 12 | mod rpad; 13 | mod starts_with; 14 | mod substring; 15 | mod trim; 16 | mod upcase; 17 | 18 | pub use capitalize::SubCommand as StrCapitalize; 19 | pub use case::*; 20 | pub use collect::*; 21 | pub use contains::SubCommand as StrContains; 22 | pub use downcase::SubCommand as StrDowncase; 23 | pub use ends_with::SubCommand as StrEndswith; 24 | pub use find_replace::SubCommand as StrFindReplace; 25 | pub use index_of::SubCommand as StrIndexOf; 26 | pub use length::SubCommand as StrLength; 27 | pub use lpad::SubCommand as StrLpad; 28 | pub use reverse::SubCommand as StrReverse; 29 | pub use rpad::SubCommand as StrRpad; 30 | pub use starts_with::SubCommand as StrStartsWith; 31 | pub use substring::SubCommand as StrSubstring; 32 | pub use trim::Trim as StrTrim; 33 | pub use upcase::SubCommand as StrUpcase; 34 | -------------------------------------------------------------------------------- /crates/nu-command/src/strings/str_/trim/mod.rs: -------------------------------------------------------------------------------- 1 | mod trim_; 2 | pub use trim_::SubCommand as Trim; 3 | -------------------------------------------------------------------------------- /crates/nu-command/src/system/mod.rs: -------------------------------------------------------------------------------- 1 | mod benchmark; 2 | mod exec; 3 | mod ps; 4 | mod run_external; 5 | mod sys; 6 | mod which_; 7 | 8 | pub use benchmark::Benchmark; 9 | pub use exec::Exec; 10 | pub use ps::Ps; 11 | pub use run_external::{External, ExternalCommand}; 12 | pub use sys::Sys; 13 | pub use which_::Which; 14 | -------------------------------------------------------------------------------- /crates/nu-command/src/viewers/mod.rs: -------------------------------------------------------------------------------- 1 | mod griddle; 2 | mod icons; 3 | mod table; 4 | 5 | pub use griddle::Griddle; 6 | pub use table::Table; 7 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/any.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn checks_any_row_is_true() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | echo [ "Ecuador", "USA", "New Zealand" ] 9 | | any? $it == "New Zealand" 10 | "# 11 | )); 12 | 13 | assert_eq!(actual.out, "true"); 14 | } 15 | 16 | #[test] 17 | fn checks_any_column_of_a_table_is_true() { 18 | let actual = nu!( 19 | cwd: ".", pipeline( 20 | r#" 21 | echo [ 22 | [ first_name, last_name, rusty_at, likes ]; 23 | [ Andrés, Robalino, 10/11/2013, 1 ] 24 | [ Jonathan, Turner, 10/12/2013, 1 ] 25 | [ Darren, Schroeder, 10/11/2013, 1 ] 26 | [ Yehuda, Katz, 10/11/2013, 1 ] 27 | ] 28 | | any? rusty_at == 10/12/2013 29 | "# 30 | )); 31 | 32 | assert_eq!(actual.out, "true"); 33 | } 34 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/append.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn adds_a_row_to_the_end() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | echo [ "Andrés N. Robalino", "Jonathan Turner", "Yehuda Katz" ] 9 | | append "pollo loco" 10 | | nth 3 11 | "# 12 | )); 13 | 14 | assert_eq!(actual.out, "pollo loco"); 15 | } 16 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/def.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::nu; 2 | use nu_test_support::playground::Playground; 3 | use std::fs; 4 | 5 | // FIXME: jt: needs more work 6 | #[ignore] 7 | #[test] 8 | fn def_with_comment() { 9 | Playground::setup("def_with_comment", |dirs, _| { 10 | let data = r#" 11 | #My echo 12 | def e [arg] {echo $arg} 13 | "#; 14 | fs::write(dirs.root().join("def_test"), data).expect("Unable to write file"); 15 | let actual = nu!( 16 | cwd: dirs.root(), 17 | "source def_test; help e | to json" 18 | ); 19 | 20 | assert!(actual.out.contains("My echo\\n\\n")); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/default.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn adds_row_data_if_column_missing() { 7 | Playground::setup("default_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![FileWithContentToBeTrimmed( 9 | "los_tres_amigos.json", 10 | r#" 11 | { 12 | "amigos": [ 13 | {"name": "Yehuda"}, 14 | {"name": "Jonathan", "rusty_luck": 0}, 15 | {"name": "Andres", "rusty_luck": 0}, 16 | {"name":"GorbyPuff"} 17 | ] 18 | } 19 | "#, 20 | )]); 21 | 22 | let actual = nu!( 23 | cwd: dirs.test(), pipeline( 24 | r#" 25 | open los_tres_amigos.json 26 | | get amigos 27 | | default rusty_luck 1 28 | | where rusty_luck == 1 29 | | length 30 | "# 31 | )); 32 | 33 | assert_eq!(actual.out, "2"); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/echo.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn echo_range_is_lazy() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | echo 1..10000000000 | first 3 | to json --raw 9 | "# 10 | )); 11 | 12 | assert_eq!(actual.out, "[1,2,3]"); 13 | } 14 | 15 | #[test] 16 | fn echo_range_handles_inclusive() { 17 | let actual = nu!( 18 | cwd: "tests/fixtures/formats", pipeline( 19 | r#" 20 | echo 1..3 | each { $it } | to json --raw 21 | "# 22 | )); 23 | 24 | assert_eq!(actual.out, "[1,2,3]"); 25 | } 26 | 27 | #[test] 28 | fn echo_range_handles_exclusive() { 29 | let actual = nu!( 30 | cwd: "tests/fixtures/formats", pipeline( 31 | r#" 32 | echo 1..<3 | each { $it } | to json --raw 33 | "# 34 | )); 35 | 36 | assert_eq!(actual.out, "[1,2]"); 37 | } 38 | 39 | #[test] 40 | fn echo_range_handles_inclusive_down() { 41 | let actual = nu!( 42 | cwd: "tests/fixtures/formats", pipeline( 43 | r#" 44 | echo 3..1 | each { $it } | to json --raw 45 | "# 46 | )); 47 | 48 | assert_eq!(actual.out, "[3,2,1]"); 49 | } 50 | 51 | #[test] 52 | fn echo_range_handles_exclusive_down() { 53 | let actual = nu!( 54 | cwd: "tests/fixtures/formats", pipeline( 55 | r#" 56 | echo 3..<1 | each { $it } | to json --raw 57 | "# 58 | )); 59 | 60 | assert_eq!(actual.out, "[3,2]"); 61 | } 62 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/headers.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | // FIXME: jt: needs more work 4 | #[ignore] 5 | #[test] 6 | fn headers_uses_first_row_as_header() { 7 | let actual = nu!( 8 | cwd: "tests/fixtures/formats", pipeline( 9 | r#" 10 | open sample_headers.xlsx 11 | | get Sheet1 12 | | headers 13 | | get header0 14 | | from json"# 15 | )); 16 | 17 | assert_eq!(actual.out, "r1c0r2c0") 18 | } 19 | 20 | // FIXME: jt: needs more work 21 | #[ignore] 22 | #[test] 23 | fn headers_adds_missing_column_name() { 24 | let actual = nu!( 25 | cwd: "tests/fixtures/formats", pipeline( 26 | r#" 27 | open sample_headers.xlsx 28 | | get Sheet1 29 | | headers 30 | | get Column1 31 | | from json"# 32 | )); 33 | 34 | assert_eq!(actual.out, "r1c1r2c1") 35 | } 36 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/help.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn help_commands_length() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | help commands | length 9 | "# 10 | )); 11 | 12 | let output = actual.out; 13 | let output_int: i32 = output.parse().unwrap(); 14 | let is_positive = output_int.is_positive(); 15 | assert!(is_positive); 16 | } 17 | 18 | // FIXME: jt: needs more work 19 | #[ignore] 20 | #[test] 21 | fn help_generate_docs_length() { 22 | let actual = nu!( 23 | cwd: ".", pipeline( 24 | r#" 25 | help generate_docs | flatten | length 26 | "# 27 | )); 28 | 29 | let output = actual.out; 30 | let output_int: i32 = output.parse().unwrap(); 31 | let is_positive = output_int.is_positive(); 32 | assert!(is_positive); 33 | } 34 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/into_filesize.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn into_filesize_int() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | 1 | into filesize 9 | "# 10 | )); 11 | 12 | assert!(actual.out.contains("1 B")); 13 | } 14 | 15 | #[test] 16 | fn into_filesize_decimal() { 17 | let actual = nu!( 18 | cwd: ".", pipeline( 19 | r#" 20 | 1.2 | into filesize 21 | "# 22 | )); 23 | 24 | assert!(actual.out.contains("1 B")); 25 | } 26 | 27 | #[test] 28 | fn into_filesize_str() { 29 | let actual = nu!( 30 | cwd: ".", pipeline( 31 | r#" 32 | '2000' | into filesize 33 | "# 34 | )); 35 | 36 | assert!(actual.out.contains("2.0 KiB")); 37 | } 38 | 39 | #[test] 40 | fn into_filesize_str_newline() { 41 | let actual = nu!( 42 | cwd: ".", pipeline( 43 | r#" 44 | "2000 45 | " | into filesize 46 | "# 47 | )); 48 | 49 | assert!(actual.out.contains("2.0 KiB")); 50 | } 51 | 52 | #[test] 53 | fn into_filesize_str_many_newlines() { 54 | let actual = nu!( 55 | cwd: ".", pipeline( 56 | r#" 57 | "2000 58 | 59 | " | into filesize 60 | "# 61 | )); 62 | 63 | assert!(actual.out.contains("2.0 KiB")); 64 | } 65 | 66 | #[test] 67 | fn into_filesize_filesize() { 68 | let actual = nu!( 69 | cwd: ".", pipeline( 70 | r#" 71 | 3kib | into filesize 72 | "# 73 | )); 74 | 75 | assert!(actual.out.contains("3.0 KiB")); 76 | } 77 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/into_int.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn into_int_filesize() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | echo 1kb | into int | each { $it / 1000 } 9 | "# 10 | )); 11 | 12 | assert!(actual.out.contains('1')); 13 | } 14 | 15 | #[test] 16 | fn into_int_filesize2() { 17 | let actual = nu!( 18 | cwd: ".", pipeline( 19 | r#" 20 | echo 1kib | into int | each { $it / 1024 } 21 | "# 22 | )); 23 | 24 | assert!(actual.out.contains('1')); 25 | } 26 | 27 | #[test] 28 | fn into_int_int() { 29 | let actual = nu!( 30 | cwd: ".", pipeline( 31 | r#" 32 | echo 1024 | into int | each { $it / 1024 } 33 | "# 34 | )); 35 | 36 | assert!(actual.out.contains('1')); 37 | } 38 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/keep/mod.rs: -------------------------------------------------------------------------------- 1 | mod rows; 2 | mod until; 3 | mod while_; 4 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/keep/rows.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn rows() { 7 | Playground::setup("keep_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![FileWithContentToBeTrimmed( 9 | "caballeros.csv", 10 | r#" 11 | name,lucky_code 12 | Andrés,1 13 | Jonathan,1 14 | Jason,2 15 | Yehuda,1 16 | "#, 17 | )]); 18 | 19 | let actual = nu!( 20 | cwd: dirs.test(), pipeline( 21 | r#" 22 | open caballeros.csv 23 | | keep 3 24 | | get lucky_code 25 | | math sum 26 | "# 27 | )); 28 | 29 | assert_eq!(actual.out, "4"); 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/length.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn length_columns_in_cal_table() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | cal | length -c 9 | "# 10 | )); 11 | 12 | assert_eq!(actual.out, "7"); 13 | } 14 | 15 | #[test] 16 | fn length_columns_no_rows() { 17 | let actual = nu!( 18 | cwd: ".", pipeline( 19 | r#" 20 | echo [] | length -c 21 | "# 22 | )); 23 | 24 | assert_eq!(actual.out, "0"); 25 | } 26 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/lines.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn lines() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open cargo_sample.toml -r 9 | | lines 10 | | skip while $it != "[dependencies]" 11 | | skip 1 12 | | first 1 13 | | split column "=" 14 | | get Column1 15 | | str trim 16 | "# 17 | )); 18 | 19 | assert_eq!(actual.out, "rustyline"); 20 | } 21 | 22 | #[test] 23 | fn lines_proper_buffering() { 24 | let actual = nu!( 25 | cwd: "tests/fixtures/formats", pipeline( 26 | r#" 27 | open lines_test.txt -r 28 | | lines 29 | | str length 30 | | to json -r 31 | "# 32 | )); 33 | 34 | assert_eq!(actual.out, "[8193,3]"); 35 | } 36 | 37 | #[test] 38 | fn lines_multi_value_split() { 39 | let actual = nu!( 40 | cwd: "tests/fixtures/formats", pipeline( 41 | r#" 42 | open sample-simple.json 43 | | get first second 44 | | lines 45 | | length 46 | "# 47 | )); 48 | 49 | assert_eq!(actual.out, "6"); 50 | } 51 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/math/avg.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn can_average_numbers() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open sgml_description.json 9 | | get glossary.GlossDiv.GlossList.GlossEntry.Sections 10 | | math avg 11 | "# 12 | )); 13 | 14 | assert_eq!(actual.out, "101.5") 15 | } 16 | 17 | #[test] 18 | fn can_average_bytes() { 19 | let actual = nu!( 20 | cwd: "tests/fixtures/formats", 21 | "ls | sort-by name | skip 1 | first 2 | get size | math avg | to json -r" 22 | ); 23 | 24 | assert_eq!(actual.out, "1600"); 25 | } 26 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/math/median.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn median_numbers_with_even_rows() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | echo [10 6 19 21 4] 9 | | math median 10 | "# 11 | )); 12 | 13 | assert_eq!(actual.out, "10") 14 | } 15 | 16 | #[test] 17 | fn median_numbers_with_odd_rows() { 18 | let actual = nu!( 19 | cwd: ".", pipeline( 20 | r#" 21 | echo [3 8 9 12 12 15] 22 | | math median 23 | "# 24 | )); 25 | 26 | assert_eq!(actual.out, "10.5") 27 | } 28 | 29 | #[test] 30 | fn median_mixed_numbers() { 31 | let actual = nu!( 32 | cwd: ".", pipeline( 33 | r#" 34 | echo [-11.5 -13.5 10] 35 | | math median 36 | "# 37 | )); 38 | 39 | assert_eq!(actual.out, "-11.5") 40 | } 41 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/math/round.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::nu; 2 | 3 | #[test] 4 | fn can_round_very_large_numbers() { 5 | let actual = nu!( 6 | cwd: ".", 7 | "echo 18.1372544780074142289927665486772012345 | math round" 8 | ); 9 | 10 | assert_eq!(actual.out, "18") 11 | } 12 | 13 | #[test] 14 | fn can_round_very_large_numbers_with_precision() { 15 | let actual = nu!( 16 | cwd: ".", 17 | "echo 18.13725447800741422899276654867720121457878988 | math round -p 10" 18 | ); 19 | 20 | assert_eq!(actual.out, "18.137254478") 21 | } 22 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/math/sqrt.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::nu; 2 | 3 | // FIXME: jt: needs more work 4 | #[ignore] 5 | #[test] 6 | fn can_sqrt_numbers() { 7 | let actual = nu!( 8 | cwd: ".", 9 | "echo [0.25 2 4] | math sqrt | math sum" 10 | ); 11 | 12 | assert_eq!(actual.out, "3.914213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573"); 13 | } 14 | 15 | // FIXME: jt: needs more work 16 | #[ignore] 17 | #[test] 18 | fn can_sqrt_irrational() { 19 | let actual = nu!( 20 | cwd: ".", 21 | "echo 2 | math sqrt" 22 | ); 23 | 24 | assert_eq!(actual.out, "1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573"); 25 | } 26 | 27 | #[test] 28 | fn can_sqrt_perfect_square() { 29 | let actual = nu!( 30 | cwd: ".", 31 | "echo 4 | math sqrt" 32 | ); 33 | 34 | assert_eq!(actual.out, "2"); 35 | } 36 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/merge.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | // FIXME: jt: needs more work 6 | #[ignore] 7 | #[test] 8 | fn row() { 9 | Playground::setup("merge_test_1", |dirs, sandbox| { 10 | sandbox.with_files(vec![ 11 | FileWithContentToBeTrimmed( 12 | "caballeros.csv", 13 | r#" 14 | name,country,luck 15 | Andrés,Ecuador,0 16 | Jonathan,USA,0 17 | Jason,Canada,0 18 | Yehuda,USA,0 19 | "#, 20 | ), 21 | FileWithContentToBeTrimmed( 22 | "new_caballeros.csv", 23 | r#" 24 | name,country,luck 25 | Andrés Robalino,Guayaquil Ecuador,1 26 | Jonathan Turner,New Zealand,1 27 | "#, 28 | ), 29 | ]); 30 | 31 | let actual = nu!( 32 | cwd: dirs.test(), pipeline( 33 | r#" 34 | open caballeros.csv 35 | | merge { open new_caballeros.csv } 36 | | where country in ["Guayaquil Ecuador" "New Zealand"] 37 | | get luck 38 | | math sum 39 | "# 40 | )); 41 | 42 | assert_eq!(actual.out, "2"); 43 | }) 44 | } 45 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/mod.rs: -------------------------------------------------------------------------------- 1 | mod all; 2 | mod any; 3 | mod append; 4 | mod cal; 5 | mod cd; 6 | mod compact; 7 | mod cp; 8 | mod def; 9 | mod default; 10 | mod drop; 11 | mod each; 12 | mod echo; 13 | mod empty; 14 | mod enter; 15 | mod every; 16 | mod find; 17 | mod first; 18 | mod flatten; 19 | mod format; 20 | mod get; 21 | mod group_by; 22 | mod hash_; 23 | mod headers; 24 | mod help; 25 | mod histogram; 26 | mod into_filesize; 27 | mod into_int; 28 | mod keep; 29 | mod last; 30 | mod length; 31 | mod lines; 32 | mod ls; 33 | mod math; 34 | mod merge; 35 | mod mkdir; 36 | mod move_; 37 | mod nth; 38 | mod open; 39 | mod parse; 40 | mod path; 41 | mod prepend; 42 | mod random; 43 | mod range; 44 | mod reduce; 45 | mod rename; 46 | mod reverse; 47 | mod rm; 48 | mod roll; 49 | mod rotate; 50 | mod save; 51 | mod select; 52 | mod semicolon; 53 | mod skip; 54 | mod sort_by; 55 | mod source; 56 | mod split_by; 57 | mod split_column; 58 | mod split_row; 59 | mod str_; 60 | mod touch; 61 | mod uniq; 62 | mod update; 63 | mod where_; 64 | mod which; 65 | mod with_env; 66 | mod wrap; 67 | mod zip; 68 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/move_/mod.rs: -------------------------------------------------------------------------------- 1 | mod column; 2 | mod mv; 3 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/nth.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::EmptyFile; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn selects_a_row() { 7 | Playground::setup("nth_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]); 9 | 10 | let actual = nu!( 11 | cwd: dirs.test(), pipeline( 12 | r#" 13 | ls 14 | | sort-by name 15 | | nth 0 16 | | get name 17 | "# 18 | )); 19 | 20 | assert_eq!(actual.out, "arepas.txt"); 21 | }); 22 | } 23 | 24 | #[test] 25 | fn selects_many_rows() { 26 | Playground::setup("nth_test_2", |dirs, sandbox| { 27 | sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]); 28 | 29 | let actual = nu!( 30 | cwd: dirs.test(), pipeline( 31 | r#" 32 | ls 33 | | get name 34 | | nth 1 0 35 | | length 36 | "# 37 | )); 38 | 39 | assert_eq!(actual.out, "2"); 40 | }); 41 | } 42 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/path/exists.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::EmptyFile; 2 | use nu_test_support::nu; 3 | use nu_test_support::playground::Playground; 4 | 5 | // FIXME: jt: needs more work 6 | #[ignore] 7 | #[test] 8 | fn checks_if_existing_file_exists() { 9 | Playground::setup("path_exists_1", |dirs, sandbox| { 10 | sandbox.with_files(vec![EmptyFile("spam.txt")]); 11 | 12 | let actual = nu!( 13 | cwd: dirs.test(), 14 | "echo spam.txt | path exists" 15 | ); 16 | 17 | assert_eq!(actual.out, "true"); 18 | }) 19 | } 20 | 21 | #[test] 22 | fn checks_if_missing_file_exists() { 23 | Playground::setup("path_exists_2", |dirs, _| { 24 | let actual = nu!( 25 | cwd: dirs.test(), 26 | "echo spam.txt | path exists" 27 | ); 28 | 29 | assert_eq!(actual.out, "false"); 30 | }) 31 | } 32 | 33 | #[test] 34 | fn checks_if_dot_exists() { 35 | Playground::setup("path_exists_3", |dirs, _| { 36 | let actual = nu!( 37 | cwd: dirs.test(), 38 | "echo '.' | path exists" 39 | ); 40 | 41 | assert_eq!(actual.out, "true"); 42 | }) 43 | } 44 | 45 | #[test] 46 | fn checks_if_double_dot_exists() { 47 | Playground::setup("path_exists_4", |dirs, _| { 48 | let actual = nu!( 49 | cwd: dirs.test(), 50 | "echo '..' | path exists" 51 | ); 52 | 53 | assert_eq!(actual.out, "true"); 54 | }) 55 | } 56 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/path/join.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | use super::join_path_sep; 4 | 5 | #[test] 6 | fn returns_path_joined_with_column_path() { 7 | let actual = nu!( 8 | cwd: "tests", pipeline( 9 | r#" 10 | echo [ [name]; [eggs] ] 11 | | path join spam.txt -c [ name ] 12 | | get name 13 | "# 14 | )); 15 | 16 | let expected = join_path_sep(&["eggs", "spam.txt"]); 17 | assert_eq!(actual.out, expected); 18 | } 19 | 20 | #[test] 21 | fn returns_path_joined_from_list() { 22 | let actual = nu!( 23 | cwd: "tests", pipeline( 24 | r#" 25 | echo [ home viking spam.txt ] 26 | | path join 27 | "# 28 | )); 29 | 30 | let expected = join_path_sep(&["home", "viking", "spam.txt"]); 31 | assert_eq!(actual.out, expected); 32 | } 33 | 34 | #[test] 35 | fn appends_slash_when_joined_with_empty_path() { 36 | let actual = nu!( 37 | cwd: "tests", pipeline( 38 | r#" 39 | echo "/some/dir" 40 | | path join '' 41 | "# 42 | )); 43 | 44 | let expected = join_path_sep(&["/some/dir", ""]); 45 | assert_eq!(actual.out, expected); 46 | } 47 | 48 | #[test] 49 | fn returns_joined_path_when_joining_empty_path() { 50 | let actual = nu!( 51 | cwd: "tests", pipeline( 52 | r#" 53 | echo "" 54 | | path join foo.txt 55 | "# 56 | )); 57 | 58 | assert_eq!(actual.out, "foo.txt"); 59 | } 60 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/path/mod.rs: -------------------------------------------------------------------------------- 1 | mod basename; 2 | mod dirname; 3 | mod exists; 4 | mod expand; 5 | mod join; 6 | mod parse; 7 | mod split; 8 | mod type_; 9 | 10 | use std::path::MAIN_SEPARATOR; 11 | 12 | /// Helper function that joins string literals with '/' or '\', based on host OS 13 | fn join_path_sep(pieces: &[&str]) -> String { 14 | let sep_string = String::from(MAIN_SEPARATOR); 15 | pieces.join(&sep_string) 16 | } 17 | 18 | #[cfg(windows)] 19 | #[test] 20 | fn joins_path_on_windows() { 21 | let pieces = ["sausage", "bacon", "spam"]; 22 | let actual = join_path_sep(&pieces); 23 | 24 | assert_eq!(&actual, "sausage\\bacon\\spam"); 25 | } 26 | 27 | #[cfg(not(windows))] 28 | #[test] 29 | fn joins_path_on_other_than_windows() { 30 | let pieces = ["sausage", "bacon", "spam"]; 31 | let actual = join_path_sep(&pieces); 32 | 33 | assert_eq!(&actual, "sausage/bacon/spam"); 34 | } 35 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/path/split.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn splits_empty_path() { 5 | let actual = nu!( 6 | cwd: "tests", pipeline( 7 | r#" 8 | echo '' | path split 9 | "# 10 | )); 11 | 12 | assert_eq!(actual.out, ""); 13 | } 14 | 15 | #[test] 16 | fn splits_correctly_single_path() { 17 | let actual = nu!( 18 | cwd: "tests", pipeline( 19 | r#" 20 | 'home/viking/spam.txt' 21 | | path split 22 | | last 23 | "# 24 | )); 25 | 26 | assert_eq!(actual.out, "spam.txt"); 27 | } 28 | 29 | #[test] 30 | fn splits_correctly_with_column_path() { 31 | let actual = nu!( 32 | cwd: "tests", pipeline( 33 | r#" 34 | echo [ 35 | [home, barn]; 36 | 37 | ['home/viking/spam.txt', 'barn/cow/moo.png'] 38 | ['home/viking/eggs.txt', 'barn/goat/cheese.png'] 39 | ] 40 | | path split -c [ home barn ] 41 | | get barn 42 | | flatten 43 | | length 44 | "# 45 | )); 46 | 47 | assert_eq!(actual.out, "6"); 48 | } 49 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/path/type_.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::EmptyFile; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn returns_type_of_missing_file() { 7 | let actual = nu!( 8 | cwd: "tests", pipeline( 9 | r#" 10 | echo "spam.txt" 11 | | path type 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, ""); 16 | } 17 | 18 | // FIXME: jt: needs more work 19 | #[ignore] 20 | #[test] 21 | fn returns_type_of_existing_file() { 22 | Playground::setup("path_expand_1", |dirs, sandbox| { 23 | sandbox 24 | .within("menu") 25 | .with_files(vec![EmptyFile("spam.txt")]); 26 | 27 | let actual = nu!( 28 | cwd: dirs.test(), pipeline( 29 | r#" 30 | echo "menu" 31 | | path type 32 | "# 33 | )); 34 | 35 | assert_eq!(actual.out, "dir"); 36 | }) 37 | } 38 | 39 | // FIXME: jt: needs more work 40 | #[ignore] 41 | #[test] 42 | fn returns_type_of_existing_directory() { 43 | Playground::setup("path_expand_1", |dirs, sandbox| { 44 | sandbox 45 | .within("menu") 46 | .with_files(vec![EmptyFile("spam.txt")]); 47 | 48 | let actual = nu!( 49 | cwd: dirs.test(), pipeline( 50 | r#" 51 | echo "menu/spam.txt" 52 | | path type 53 | "# 54 | )); 55 | 56 | assert_eq!(actual.out, "file"); 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/prepend.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn adds_a_row_to_the_beginning() { 7 | Playground::setup("prepend_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![FileWithContentToBeTrimmed( 9 | "los_tres_caballeros.txt", 10 | r#" 11 | Andrés N. Robalino 12 | Jonathan Turner 13 | Yehuda Katz 14 | "#, 15 | )]); 16 | 17 | let actual = nu!( 18 | cwd: dirs.test(), pipeline( 19 | r#" 20 | open los_tres_caballeros.txt 21 | | lines 22 | | prepend "pollo loco" 23 | | nth 0 24 | "# 25 | )); 26 | 27 | assert_eq!(actual.out, "pollo loco"); 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/bool.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn generates_a_bool() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | random bool 9 | "# 10 | )); 11 | 12 | let output = actual.out; 13 | let is_boolean_output = output == "true" || output == "false"; 14 | 15 | assert!(is_boolean_output); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/chars.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn generates_chars_of_specified_length() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | random chars -l 15 | size | get chars 9 | "# 10 | )); 11 | 12 | let result = actual.out; 13 | assert_eq!(result, "15"); 14 | } 15 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/decimal.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | // FIXME: jt: needs more work 4 | #[ignore] 5 | #[test] 6 | fn generates_an_decimal() { 7 | let actual = nu!( 8 | cwd: ".", pipeline( 9 | r#" 10 | random decimal 42..43 11 | "# 12 | )); 13 | 14 | assert!(actual.out.contains("42") || actual.out.contains("43")); 15 | } 16 | 17 | // FIXME: jt: needs more work 18 | #[ignore] 19 | #[test] 20 | fn generates_55() { 21 | let actual = nu!( 22 | cwd: ".", pipeline( 23 | r#" 24 | random decimal 55..55 25 | "# 26 | )); 27 | 28 | assert!(actual.out.contains("55")); 29 | } 30 | 31 | // FIXME: jt: needs more work 32 | #[ignore] 33 | #[test] 34 | fn generates_0() { 35 | let actual = nu!( 36 | cwd: ".", pipeline( 37 | r#" 38 | random decimal ..<1 39 | "# 40 | )); 41 | 42 | assert!(actual.out.contains('0')); 43 | } 44 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/dice.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn rolls_4_roll() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | random dice -d 4 -s 10 | length 9 | "# 10 | )); 11 | 12 | assert_eq!(actual.out, "4"); 13 | } 14 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/integer.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn generates_an_integer() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | random integer 42..43 9 | "# 10 | )); 11 | 12 | assert!(actual.out.contains("42") || actual.out.contains("43")); 13 | } 14 | 15 | #[test] 16 | fn generates_55() { 17 | let actual = nu!( 18 | cwd: ".", pipeline( 19 | r#" 20 | random integer 55..55 21 | "# 22 | )); 23 | 24 | assert!(actual.out.contains("55")); 25 | } 26 | 27 | // FIXME: jt: needs more work 28 | #[ignore] 29 | #[test] 30 | fn generates_0() { 31 | let actual = nu!( 32 | cwd: ".", pipeline( 33 | r#" 34 | random integer ..<1 35 | "# 36 | )); 37 | 38 | assert!(actual.out.contains('0')); 39 | } 40 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/mod.rs: -------------------------------------------------------------------------------- 1 | mod bool; 2 | mod chars; 3 | mod decimal; 4 | mod dice; 5 | mod integer; 6 | #[cfg(feature = "uuid_crate")] 7 | mod uuid; 8 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/random/uuid.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | use uuid_crate::Uuid; 3 | 4 | #[test] 5 | fn generates_valid_uuid4() { 6 | let actual = nu!( 7 | cwd: ".", pipeline( 8 | r#" 9 | random uuid 10 | "# 11 | )); 12 | 13 | let result = Uuid::parse_str(actual.out.as_str()); 14 | 15 | assert!(result.is_ok()); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/reverse.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::nu; 2 | 3 | #[test] 4 | fn can_get_reverse_first() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", 7 | "ls | sort-by name | reverse | first 1 | get name | str trim " 8 | ); 9 | 10 | assert_eq!(actual.out, "utf16.ini"); 11 | } 12 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/semicolon.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::playground::Playground; 2 | use nu_test_support::{nu, pipeline}; 3 | 4 | #[test] 5 | fn semicolon_allows_lhs_to_complete() { 6 | Playground::setup("create_test_1", |dirs, _sandbox| { 7 | let actual = nu!( 8 | cwd: dirs.test(), 9 | "touch i_will_be_created_semi.txt; echo done" 10 | ); 11 | 12 | let path = dirs.test().join("i_will_be_created_semi.txt"); 13 | 14 | assert!(path.exists()); 15 | assert_eq!(actual.out, "done"); 16 | }) 17 | } 18 | 19 | #[test] 20 | fn semicolon_lhs_error_stops_processing() { 21 | let actual = nu!( 22 | cwd: "tests/fixtures/formats", pipeline( 23 | r#" 24 | where 1 1; echo done 25 | "# 26 | )); 27 | 28 | assert!(!actual.out.contains("done")); 29 | } 30 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/skip/mod.rs: -------------------------------------------------------------------------------- 1 | mod until; 2 | mod while_; 3 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/split_column.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn to_column() { 7 | Playground::setup("split_column_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![FileWithContentToBeTrimmed( 9 | "sample.txt", 10 | r#" 11 | importer,shipper,tariff_item,name,origin 12 | "#, 13 | )]); 14 | 15 | let actual = nu!( 16 | cwd: dirs.test(), pipeline( 17 | r#" 18 | open sample.txt 19 | | lines 20 | | str trim 21 | | split column "," 22 | | get Column2 23 | "# 24 | )); 25 | 26 | assert!(actual.out.contains("shipper")); 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/split_row.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; 2 | use nu_test_support::playground::Playground; 3 | use nu_test_support::{nu, pipeline}; 4 | 5 | #[test] 6 | fn to_row() { 7 | Playground::setup("split_row_test_1", |dirs, sandbox| { 8 | sandbox.with_files(vec![FileWithContentToBeTrimmed( 9 | "sample.txt", 10 | r#" 11 | importer,shipper,tariff_item,name,origin 12 | "#, 13 | )]); 14 | 15 | let actual = nu!( 16 | cwd: dirs.test(), pipeline( 17 | r#" 18 | open sample.txt 19 | | lines 20 | | str trim 21 | | split row "," 22 | | length 23 | "# 24 | )); 25 | 26 | assert!(actual.out.contains('5')); 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/str_/collect.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn test_1() { 5 | let actual = nu!( 6 | cwd: ".", pipeline( 7 | r#" 8 | echo 1..5 | into string | str collect 9 | "# 10 | ) 11 | ); 12 | 13 | assert_eq!(actual.out, "12345"); 14 | } 15 | 16 | #[test] 17 | fn test_2() { 18 | let actual = nu!( 19 | cwd: ".", pipeline( 20 | r#" 21 | echo [a b c d] | str collect "" 22 | "# 23 | ) 24 | ); 25 | 26 | assert_eq!(actual.out, "abcd"); 27 | } 28 | 29 | #[test] 30 | fn construct_a_path() { 31 | let actual = nu!( 32 | cwd: ".", pipeline( 33 | r#" 34 | echo [sample txt] | str collect "." 35 | "# 36 | ) 37 | ); 38 | 39 | assert_eq!(actual.out, "sample.txt"); 40 | } 41 | 42 | #[test] 43 | fn sum_one_to_four() { 44 | let actual = nu!( 45 | cwd: ".", pipeline( 46 | r#" 47 | 1..4 | each { $it } | into string | str collect "+" | math eval 48 | "# 49 | ) 50 | ); 51 | 52 | assert!(actual.out.contains("10")); 53 | } 54 | -------------------------------------------------------------------------------- /crates/nu-command/tests/commands/touch.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::nu; 2 | use nu_test_support::playground::Playground; 3 | 4 | #[test] 5 | fn creates_a_file_when_it_doesnt_exist() { 6 | Playground::setup("create_test_1", |dirs, _sandbox| { 7 | nu!( 8 | cwd: dirs.test(), 9 | "touch i_will_be_created.txt" 10 | ); 11 | 12 | let path = dirs.test().join("i_will_be_created.txt"); 13 | assert!(path.exists()); 14 | }) 15 | } 16 | 17 | #[test] 18 | fn creates_two_files() { 19 | Playground::setup("create_test_2", |dirs, _sandbox| { 20 | nu!( 21 | cwd: dirs.test(), 22 | "touch a b" 23 | ); 24 | 25 | let path = dirs.test().join("a"); 26 | assert!(path.exists()); 27 | 28 | let path2 = dirs.test().join("b"); 29 | assert!(path2.exists()); 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/bson.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "bson")] 2 | #[test] 3 | fn table_to_bson_and_back_into_table() { 4 | use nu_test_support::{nu, pipeline}; 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open sample.bson 9 | | to bson 10 | | from bson 11 | | get root 12 | | get 1.b 13 | "# 14 | )); 15 | 16 | assert_eq!(actual.out, "whel"); 17 | } 18 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/mod.rs: -------------------------------------------------------------------------------- 1 | mod bson; 2 | mod csv; 3 | mod eml; 4 | mod html; 5 | mod ics; 6 | mod json; 7 | mod markdown; 8 | mod ods; 9 | mod sqlite; 10 | mod ssv; 11 | mod toml; 12 | mod tsv; 13 | mod url; 14 | mod vcf; 15 | mod xlsx; 16 | mod xml; 17 | mod yaml; 18 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/ods.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn from_ods_file_to_table() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open sample_data.ods 9 | | get SalesOrders 10 | | nth 4 11 | | get Column2 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "Gill"); 16 | } 17 | 18 | #[test] 19 | fn from_ods_file_to_table_select_sheet() { 20 | let actual = nu!( 21 | cwd: "tests/fixtures/formats", pipeline( 22 | r#" 23 | open sample_data.ods --raw 24 | | from ods -s ["SalesOrders"] 25 | | columns 26 | | get 0 27 | "# 28 | )); 29 | 30 | assert_eq!(actual.out, "SalesOrders"); 31 | } 32 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/sqlite.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "sqlite")] 2 | use nu_test_support::{nu, pipeline}; 3 | 4 | #[cfg(feature = "sqlite")] 5 | #[test] 6 | fn table_to_sqlite_and_back_into_table() { 7 | let actual = nu!( 8 | cwd: "tests/fixtures/formats", pipeline( 9 | r#" 10 | open sample.db 11 | | to sqlite 12 | | from sqlite 13 | | get table_values 14 | | nth 2 15 | | get x 16 | "# 17 | )); 18 | 19 | assert_eq!(actual.out, "hello"); 20 | } 21 | 22 | #[cfg(feature = "sqlite")] 23 | #[test] 24 | fn table_to_sqlite_and_back_into_table_select_table() { 25 | let actual = nu!( 26 | cwd: "tests/fixtures/formats", pipeline( 27 | r#" 28 | open sample.db 29 | | to sqlite 30 | | from sqlite -t [strings] 31 | | get table_names 32 | "# 33 | )); 34 | 35 | assert_eq!(actual.out, "strings"); 36 | } 37 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/toml.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn table_to_toml_text_and_from_toml_text_back_into_table() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open cargo_sample.toml 9 | | to toml 10 | | from toml 11 | | get package.name 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "nu"); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/url.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn can_encode_and_decode_urlencoding() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open sample.url 9 | | to url 10 | | from url 11 | | get cheese 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "comté"); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/xlsx.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn from_excel_file_to_table() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open sample_data.xlsx 9 | | get SalesOrders 10 | | nth 4 11 | | get Column2 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "Gill"); 16 | } 17 | 18 | #[test] 19 | fn from_excel_file_to_table_select_sheet() { 20 | let actual = nu!( 21 | cwd: "tests/fixtures/formats", pipeline( 22 | r#" 23 | open sample_data.xlsx --raw 24 | | from xlsx -s ["SalesOrders"] 25 | | columns 26 | | get 0 27 | "# 28 | )); 29 | 30 | assert_eq!(actual.out, "SalesOrders"); 31 | } 32 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/xml.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn table_to_xml_text_and_from_xml_text_back_into_table() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open jonathan.xml 9 | | to xml 10 | | from xml 11 | | get rss.children.channel.children.0.3.item.children.guid.4.attributes.isPermaLink 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "true"); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/format_conversions/yaml.rs: -------------------------------------------------------------------------------- 1 | use nu_test_support::{nu, pipeline}; 2 | 3 | #[test] 4 | fn table_to_yaml_text_and_from_yaml_text_back_into_table() { 5 | let actual = nu!( 6 | cwd: "tests/fixtures/formats", pipeline( 7 | r#" 8 | open appveyor.yml 9 | | to yaml 10 | | from yaml 11 | | get environment.global.PROJECT_NAME 12 | "# 13 | )); 14 | 15 | assert_eq!(actual.out, "nushell"); 16 | } 17 | -------------------------------------------------------------------------------- /crates/nu-command/tests/main.rs: -------------------------------------------------------------------------------- 1 | use nu_command::create_default_context; 2 | use nu_protocol::engine::StateWorkingSet; 3 | use quickcheck_macros::quickcheck; 4 | 5 | mod commands; 6 | mod format_conversions; 7 | 8 | // use nu_engine::EvaluationContext; 9 | 10 | #[quickcheck] 11 | fn quickcheck_parse(data: String) -> bool { 12 | let (tokens, err) = nu_parser::lex(data.as_bytes(), 0, b"", b"", true); 13 | let (lite_block, err2) = nu_parser::lite_parse(&tokens); 14 | 15 | if err.is_none() && err2.is_none() { 16 | let cwd = std::env::current_dir().expect("Could not get current working directory."); 17 | let context = create_default_context(cwd); 18 | { 19 | let mut working_set = StateWorkingSet::new(&context); 20 | working_set.add_file("quickcheck".into(), data.as_bytes()); 21 | 22 | let _ = nu_parser::parse_block(&mut working_set, &lite_block, false); 23 | } 24 | } 25 | true 26 | } 27 | -------------------------------------------------------------------------------- /crates/nu-engine/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-engine" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | nu-protocol = { path = "../nu-protocol", features = ["plugin"] } 8 | nu-path = { path = "../nu-path" } 9 | itertools = "0.10.1" 10 | chrono = { version="0.4.19", features=["serde"] } 11 | glob = "0.3.0" 12 | 13 | [features] 14 | plugin = [] 15 | -------------------------------------------------------------------------------- /crates/nu-engine/src/column.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::Value; 2 | use std::collections::HashSet; 3 | 4 | pub fn get_columns(input: &[Value]) -> Vec { 5 | let mut columns = vec![]; 6 | 7 | for item in input { 8 | if let Value::Record { cols, vals: _, .. } = item { 9 | for col in cols { 10 | if !columns.contains(col) { 11 | columns.push(col.to_string()); 12 | } 13 | } 14 | } 15 | } 16 | 17 | columns 18 | } 19 | 20 | /* 21 | * Check to see if any of the columns inside the input 22 | * does not exist in a vec of columns 23 | */ 24 | 25 | pub fn column_does_not_exist(inputs: Vec, columns: Vec) -> bool { 26 | let mut set = HashSet::new(); 27 | for column in columns { 28 | set.insert(column); 29 | } 30 | 31 | for input in &inputs { 32 | if set.contains(input) { 33 | continue; 34 | } 35 | return true; 36 | } 37 | false 38 | } 39 | -------------------------------------------------------------------------------- /crates/nu-engine/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod call_ext; 2 | pub mod column; 3 | pub mod documentation; 4 | pub mod env; 5 | mod eval; 6 | mod glob_from; 7 | 8 | pub use call_ext::CallExt; 9 | pub use column::get_columns; 10 | pub use documentation::{generate_docs, get_brief_help, get_documentation, get_full_help}; 11 | pub use env::*; 12 | pub use eval::{ 13 | eval_block, eval_block_with_redirect, eval_expression, eval_expression_with_input, 14 | eval_operator, eval_subexpression, 15 | }; 16 | pub use glob_from::glob_from; 17 | -------------------------------------------------------------------------------- /crates/nu-json/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors", "Christian Zangl "] 3 | description = "Fork of serde-hjson" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu-json" 7 | version = "0.37.1" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [features] 12 | preserve_order = ["linked-hash-map", "linked-hash-map/serde_impl"] 13 | default = ["preserve_order"] 14 | 15 | [dependencies] 16 | serde = "1.0" 17 | num-traits = "0.2.14" 18 | regex = "^1.0" 19 | lazy_static = "1" 20 | linked-hash-map = { version="0.5", optional=true } 21 | 22 | [dev-dependencies] 23 | nu-path = { version = "0.37.1", path="../nu-path" } 24 | serde_json = "1.0.39" 25 | -------------------------------------------------------------------------------- /crates/nu-json/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 The Rust Project Developers 4 | Copyright (c) 2016 Christian Zangl 5 | Copyright (c) 2020 The Nu Project Contributors 6 | 7 | Permission is hereby granted, free of charge, to any 8 | person obtaining a copy of this software and associated 9 | documentation files (the "Software"), to deal in the 10 | Software without restriction, including without 11 | limitation the rights to use, copy, modify, merge, 12 | publish, distribute, sublicense, and/or sell copies of 13 | the Software, and to permit persons to whom the Software 14 | is furnished to do so, subject to the following 15 | conditions: 16 | 17 | The above copyright notice and this permission notice 18 | shall be included in all copies or substantial portions 19 | of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 22 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 23 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 24 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 25 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 26 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 28 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | -------------------------------------------------------------------------------- /crates/nu-json/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use self::de::{ 2 | from_iter, from_reader, from_slice, from_str, Deserializer, StreamDeserializer, 3 | }; 4 | pub use self::error::{Error, ErrorCode, Result}; 5 | pub use self::ser::{to_string, to_string_raw, to_vec, to_writer, Serializer}; 6 | pub use self::value::{from_value, to_value, Map, Value}; 7 | 8 | pub mod builder; 9 | pub mod de; 10 | pub mod error; 11 | pub mod ser; 12 | mod util; 13 | pub mod value; 14 | -------------------------------------------------------------------------------- /crates/nu-parser/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-parser" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | miette = "3.0.0" 8 | thiserror = "1.0.29" 9 | serde_json = "1.0" 10 | nu-path = {path = "../nu-path"} 11 | nu-protocol = { path = "../nu-protocol"} 12 | nu-plugin = { path = "../nu-plugin", optional = true } 13 | log = "0.4" 14 | 15 | [features] 16 | plugin = ["nu-plugin"] 17 | -------------------------------------------------------------------------------- /crates/nu-parser/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod errors; 2 | mod flatten; 3 | mod lex; 4 | mod lite_parse; 5 | mod parse_keywords; 6 | mod parser; 7 | mod type_check; 8 | 9 | pub use errors::ParseError; 10 | pub use flatten::{ 11 | flatten_block, flatten_expression, flatten_pipeline, flatten_statement, FlatShape, 12 | }; 13 | pub use lex::{lex, Token, TokenContents}; 14 | pub use lite_parse::{lite_parse, LiteBlock}; 15 | 16 | pub use parser::{find_captures_in_expr, parse, parse_block, trim_quotes, Import}; 17 | 18 | #[cfg(feature = "plugin")] 19 | pub use parse_keywords::parse_register; 20 | -------------------------------------------------------------------------------- /crates/nu-path/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "Path handling library for Nushell" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu-path" 7 | version = "0.37.1" 8 | 9 | [dependencies] 10 | dirs-next = "2.0.0" 11 | dunce = "1.0.1" 12 | -------------------------------------------------------------------------------- /crates/nu-path/README.md: -------------------------------------------------------------------------------- 1 | # nu-path 2 | 3 | This crate takes care of path handling in Nushell, such as canonicalization and component expansion, as well as other path-related utilities. 4 | -------------------------------------------------------------------------------- /crates/nu-path/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | pub fn home_dir() -> Option { 4 | dirs_next::home_dir() 5 | } 6 | 7 | pub fn config_dir() -> Option { 8 | dirs_next::config_dir() 9 | } 10 | -------------------------------------------------------------------------------- /crates/nu-path/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod dots; 2 | mod expansions; 3 | mod helpers; 4 | mod tilde; 5 | mod util; 6 | 7 | pub use expansions::{canonicalize_with, expand_path_with}; 8 | pub use helpers::{config_dir, home_dir}; 9 | pub use tilde::expand_tilde; 10 | pub use util::trim_trailing_slash; 11 | -------------------------------------------------------------------------------- /crates/nu-path/src/util.rs: -------------------------------------------------------------------------------- 1 | /// Trim trailing path separator from a string 2 | pub fn trim_trailing_slash(s: &str) -> &str { 3 | s.trim_end_matches(std::path::is_separator) 4 | } 5 | -------------------------------------------------------------------------------- /crates/nu-path/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod util; 2 | -------------------------------------------------------------------------------- /crates/nu-path/tests/util.rs: -------------------------------------------------------------------------------- 1 | use nu_path::trim_trailing_slash; 2 | use std::path::MAIN_SEPARATOR; 3 | 4 | /// Helper function that joins string literals with '/' or '\', based on the host OS 5 | fn join_path_sep(pieces: &[&str]) -> String { 6 | let sep_string = String::from(MAIN_SEPARATOR); 7 | pieces.join(&sep_string) 8 | } 9 | 10 | #[test] 11 | fn trims_trailing_slash_without_trailing_slash() { 12 | let path = join_path_sep(&["some", "path"]); 13 | 14 | let actual = trim_trailing_slash(&path); 15 | 16 | assert_eq!(actual, &path) 17 | } 18 | 19 | #[test] 20 | fn trims_trailing_slash() { 21 | let path = join_path_sep(&["some", "path", ""]); 22 | 23 | let actual = trim_trailing_slash(&path); 24 | let expected = join_path_sep(&["some", "path"]); 25 | 26 | assert_eq!(actual, &expected) 27 | } 28 | 29 | #[test] 30 | fn trims_many_trailing_slashes() { 31 | let path = join_path_sep(&["some", "path", "", "", "", ""]); 32 | 33 | let actual = trim_trailing_slash(&path); 34 | let expected = join_path_sep(&["some", "path"]); 35 | 36 | assert_eq!(actual, &expected) 37 | } 38 | 39 | #[test] 40 | fn trims_trailing_slash_empty() { 41 | let path = String::from(MAIN_SEPARATOR); 42 | let actual = trim_trailing_slash(&path); 43 | 44 | assert_eq!(actual, "") 45 | } 46 | -------------------------------------------------------------------------------- /crates/nu-plugin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-plugin" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | capnp = "0.14.3" 8 | nu-protocol = { path = "../nu-protocol" } 9 | nu-engine = { path = "../nu-engine" } 10 | serde = {version = "1.0.130", features = ["derive"]} 11 | serde_json = { version = "1.0"} 12 | -------------------------------------------------------------------------------- /crates/nu-plugin/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod plugin; 2 | mod protocol; 3 | mod serializers; 4 | 5 | #[allow(dead_code)] 6 | mod plugin_capnp; 7 | 8 | pub use plugin::{get_signature, serve_plugin, Plugin, PluginDeclaration}; 9 | pub use protocol::{EvaluatedCall, LabeledError}; 10 | pub use serializers::{capnp::CapnpSerializer, json::JsonSerializer, EncodingType}; 11 | -------------------------------------------------------------------------------- /crates/nu-plugin/src/plugin/is_plugin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/crates/nu-plugin/src/plugin/is_plugin -------------------------------------------------------------------------------- /crates/nu-plugin/src/serializers/capnp/mod.rs: -------------------------------------------------------------------------------- 1 | mod call; 2 | mod plugin_call; 3 | mod signature; 4 | mod value; 5 | 6 | use nu_protocol::ShellError; 7 | 8 | use crate::{plugin::PluginEncoder, protocol::PluginResponse}; 9 | 10 | #[derive(Clone)] 11 | pub struct CapnpSerializer; 12 | 13 | impl PluginEncoder for CapnpSerializer { 14 | fn encode_call( 15 | &self, 16 | plugin_call: &crate::protocol::PluginCall, 17 | writer: &mut impl std::io::Write, 18 | ) -> Result<(), nu_protocol::ShellError> { 19 | plugin_call::encode_call(plugin_call, writer) 20 | } 21 | 22 | fn decode_call( 23 | &self, 24 | reader: &mut impl std::io::BufRead, 25 | ) -> Result { 26 | plugin_call::decode_call(reader) 27 | } 28 | 29 | fn encode_response( 30 | &self, 31 | plugin_response: &PluginResponse, 32 | writer: &mut impl std::io::Write, 33 | ) -> Result<(), ShellError> { 34 | plugin_call::encode_response(plugin_response, writer) 35 | } 36 | 37 | fn decode_response( 38 | &self, 39 | reader: &mut impl std::io::BufRead, 40 | ) -> Result { 41 | plugin_call::decode_response(reader) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /crates/nu-pretty-hex/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Andrei Volnin ", "The Nu Project Contributors"] 3 | description = "Pretty hex dump of bytes slice in the common style." 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu-pretty-hex" 7 | version = "0.41.0" 8 | 9 | [lib] 10 | doctest = false 11 | name = "nu_pretty_hex" 12 | path = "src/lib.rs" 13 | 14 | [[bin]] 15 | name = "nu_pretty_hex" 16 | path = "src/main.rs" 17 | 18 | [dependencies] 19 | nu-ansi-term = "0.42.0" 20 | rand = "0.8.3" 21 | 22 | [dev-dependencies] 23 | heapless = { version = "0.7.8", default-features = false } 24 | 25 | # [features] 26 | # default = ["alloc"] 27 | # alloc = [] 28 | -------------------------------------------------------------------------------- /crates/nu-pretty-hex/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Andrei Volnin 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 | -------------------------------------------------------------------------------- /crates/nu-pretty-hex/tests/256.txt: -------------------------------------------------------------------------------- 1 | Length: 256 (0x100) bytes 2 | 0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................ 3 | 0010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................ 4 | 0020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !"#$%&'()*+,-./ 5 | 0030: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>? 6 | 0040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO 7 | 0050: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\]^_ 8 | 0060: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno 9 | 0070: 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvwxyz{|}~. 10 | 0080: 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................ 11 | 0090: 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................ 12 | 00a0: a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ................ 13 | 00b0: b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ................ 14 | 00c0: c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ................ 15 | 00d0: d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ................ 16 | 00e0: e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ................ 17 | 00f0: f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff ................ -------------------------------------------------------------------------------- /crates/nu-pretty-hex/tests/data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/crates/nu-pretty-hex/tests/data -------------------------------------------------------------------------------- /crates/nu-protocol/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nu-protocol" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | thiserror = "1.0.29" 10 | miette = "3.0.0" 11 | serde = {version = "1.0.130", features = ["derive"]} 12 | chrono = { version="0.4.19", features=["serde"] } 13 | indexmap = { version="1.7", features=["serde-1"] } 14 | chrono-humanize = "0.2.1" 15 | byte-unit = "4.0.9" 16 | im = "15.0.0" 17 | serde_json = { version = "1.0", optional = true } 18 | nu-json = { path = "../nu-json" } 19 | typetag = "0.1.8" 20 | num-format = "0.4.0" 21 | sys-locale = "0.1.0" 22 | 23 | [features] 24 | plugin = ["serde_json"] 25 | 26 | [dev-dependencies] 27 | serde_json = "1.0" 28 | -------------------------------------------------------------------------------- /crates/nu-protocol/README.md: -------------------------------------------------------------------------------- 1 | # nu-protocol 2 | 3 | The nu-protocol crate holds the definitions of structs/traits that are used throughout Nushell. This gives us one way to expose them to many other crates, as well as make these definitions available to each other, without causing mutually recursive dependencies. -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/call.rs: -------------------------------------------------------------------------------- 1 | use super::Expression; 2 | use crate::{DeclId, Span, Spanned}; 3 | 4 | #[derive(Debug, Clone)] 5 | pub struct Call { 6 | /// identifier of the declaration to call 7 | pub decl_id: DeclId, 8 | pub head: Span, 9 | pub positional: Vec, 10 | pub named: Vec<(Spanned, Option)>, 11 | } 12 | 13 | impl Call { 14 | pub fn new(head: Span) -> Call { 15 | Self { 16 | decl_id: 0, 17 | head, 18 | positional: vec![], 19 | named: vec![], 20 | } 21 | } 22 | 23 | pub fn has_flag(&self, flag_name: &str) -> bool { 24 | for name in &self.named { 25 | if flag_name == name.0.item { 26 | return true; 27 | } 28 | } 29 | 30 | false 31 | } 32 | 33 | pub fn get_flag_expr(&self, flag_name: &str) -> Option { 34 | for name in &self.named { 35 | if flag_name == name.0.item { 36 | return name.1.clone(); 37 | } 38 | } 39 | 40 | None 41 | } 42 | 43 | pub fn get_named_arg(&self, flag_name: &str) -> Option> { 44 | for name in &self.named { 45 | if flag_name == name.0.item { 46 | return Some(name.0.clone()); 47 | } 48 | } 49 | 50 | None 51 | } 52 | 53 | pub fn nth(&self, pos: usize) -> Option { 54 | self.positional.get(pos).cloned() 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/cell_path.rs: -------------------------------------------------------------------------------- 1 | use super::Expression; 2 | use crate::Span; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | #[derive(Debug, Clone, Serialize, Deserialize)] 6 | pub enum PathMember { 7 | String { val: String, span: Span }, 8 | Int { val: usize, span: Span }, 9 | } 10 | 11 | impl PartialEq for PathMember { 12 | fn eq(&self, other: &Self) -> bool { 13 | match (self, other) { 14 | (Self::String { val: l_val, .. }, Self::String { val: r_val, .. }) => l_val == r_val, 15 | (Self::Int { val: l_val, .. }, Self::Int { val: r_val, .. }) => l_val == r_val, 16 | _ => false, 17 | } 18 | } 19 | } 20 | 21 | #[derive(Debug, Clone, Serialize, Deserialize)] 22 | pub struct CellPath { 23 | pub members: Vec, 24 | } 25 | 26 | impl CellPath { 27 | pub fn into_string(&self) -> String { 28 | let mut output = String::new(); 29 | 30 | for (idx, elem) in self.members.iter().enumerate() { 31 | if idx > 0 { 32 | output.push('.'); 33 | } 34 | match elem { 35 | PathMember::Int { val, .. } => output.push_str(&format!("{}", val)), 36 | PathMember::String { val, .. } => output.push_str(val), 37 | } 38 | } 39 | 40 | output 41 | } 42 | } 43 | 44 | #[derive(Debug, Clone)] 45 | pub struct FullCellPath { 46 | pub head: Expression, 47 | pub tail: Vec, 48 | } 49 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/expr.rs: -------------------------------------------------------------------------------- 1 | use super::{Call, CellPath, Expression, FullCellPath, Operator, RangeOperator}; 2 | use crate::{ast::ImportPattern, BlockId, Signature, Span, Spanned, Unit, VarId}; 3 | 4 | #[derive(Debug, Clone)] 5 | pub enum Expr { 6 | Bool(bool), 7 | Int(i64), 8 | Float(f64), 9 | Range( 10 | Option>, // from 11 | Option>, // next value after "from" 12 | Option>, // to 13 | RangeOperator, 14 | ), 15 | Var(VarId), 16 | VarDecl(VarId), 17 | Call(Box), 18 | ExternalCall(Box, Vec), 19 | Operator(Operator), 20 | RowCondition(BlockId), 21 | BinaryOp(Box, Box, Box), //lhs, op, rhs 22 | Subexpression(BlockId), 23 | Block(BlockId), 24 | List(Vec), 25 | Table(Vec, Vec>), 26 | Record(Vec<(Expression, Expression)>), 27 | Keyword(Vec, Span, Box), 28 | ValueWithUnit(Box, Spanned), 29 | Filepath(String), 30 | GlobPattern(String), 31 | String(String), 32 | CellPath(CellPath), 33 | FullCellPath(Box), 34 | ImportPattern(ImportPattern), 35 | Signature(Box), 36 | StringInterpolation(Vec), 37 | Nothing, 38 | Garbage, 39 | } 40 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/mod.rs: -------------------------------------------------------------------------------- 1 | mod block; 2 | mod call; 3 | mod cell_path; 4 | mod expr; 5 | mod expression; 6 | mod import_pattern; 7 | mod operator; 8 | mod pipeline; 9 | mod statement; 10 | 11 | pub use block::*; 12 | pub use call::*; 13 | pub use cell_path::*; 14 | pub use expr::*; 15 | pub use expression::*; 16 | pub use import_pattern::*; 17 | pub use operator::*; 18 | pub use pipeline::*; 19 | pub use statement::*; 20 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/pipeline.rs: -------------------------------------------------------------------------------- 1 | use crate::ast::Expression; 2 | 3 | #[derive(Debug, Clone)] 4 | pub struct Pipeline { 5 | pub expressions: Vec, 6 | } 7 | 8 | impl Default for Pipeline { 9 | fn default() -> Self { 10 | Self::new() 11 | } 12 | } 13 | 14 | impl Pipeline { 15 | pub fn new() -> Self { 16 | Self { 17 | expressions: vec![], 18 | } 19 | } 20 | 21 | pub fn from_vec(expressions: Vec) -> Pipeline { 22 | Self { expressions } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/ast/statement.rs: -------------------------------------------------------------------------------- 1 | use super::Pipeline; 2 | use crate::DeclId; 3 | 4 | #[derive(Debug, Clone)] 5 | pub enum Statement { 6 | Declaration(DeclId), 7 | Pipeline(Pipeline), 8 | } 9 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/engine/call_info.rs: -------------------------------------------------------------------------------- 1 | use crate::ast::Call; 2 | use crate::Span; 3 | 4 | #[derive(Debug, Clone)] 5 | pub struct UnevaluatedCallInfo { 6 | pub args: Call, 7 | pub name_span: Span, 8 | } 9 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/engine/capture_block.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use crate::{BlockId, Value, VarId}; 4 | 5 | #[derive(Clone, Debug)] 6 | pub struct CaptureBlock { 7 | pub block_id: BlockId, 8 | pub captures: HashMap, 9 | } 10 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/engine/mod.rs: -------------------------------------------------------------------------------- 1 | mod call_info; 2 | mod capture_block; 3 | mod command; 4 | mod engine_state; 5 | mod stack; 6 | 7 | pub use call_info::*; 8 | pub use capture_block::*; 9 | pub use command::*; 10 | pub use engine_state::*; 11 | pub use stack::*; 12 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/example.rs: -------------------------------------------------------------------------------- 1 | use crate::Value; 2 | 3 | #[derive(Debug)] 4 | pub struct Example { 5 | pub example: &'static str, 6 | pub description: &'static str, 7 | pub result: Option, 8 | } 9 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/exportable.rs: -------------------------------------------------------------------------------- 1 | use crate::{BlockId, DeclId}; 2 | 3 | pub enum Exportable { 4 | Decl(DeclId), 5 | EnvVar(BlockId), 6 | } 7 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/id.rs: -------------------------------------------------------------------------------- 1 | pub type VarId = usize; 2 | pub type DeclId = usize; 3 | pub type BlockId = usize; 4 | pub type OverlayId = usize; 5 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod ast; 2 | mod config; 3 | pub mod engine; 4 | mod example; 5 | mod exportable; 6 | mod id; 7 | mod overlay; 8 | mod pipeline_data; 9 | mod shell_error; 10 | mod signature; 11 | mod span; 12 | mod syntax_shape; 13 | mod ty; 14 | mod value; 15 | pub use value::Value; 16 | 17 | pub use config::*; 18 | pub use engine::{ 19 | CONFIG_VARIABLE_ID, ENV_VARIABLE_ID, IN_VARIABLE_ID, NU_VARIABLE_ID, SCOPE_VARIABLE_ID, 20 | }; 21 | pub use example::*; 22 | pub use exportable::*; 23 | pub use id::*; 24 | pub use overlay::*; 25 | pub use pipeline_data::*; 26 | pub use shell_error::*; 27 | pub use signature::*; 28 | pub use span::*; 29 | pub use syntax_shape::*; 30 | pub use ty::*; 31 | pub use value::CustomValue; 32 | pub use value::*; 33 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/value/from.rs: -------------------------------------------------------------------------------- 1 | use crate::{ShellError, Value}; 2 | 3 | impl Value { 4 | pub fn as_f64(&self) -> Result { 5 | match self { 6 | Value::Float { val, .. } => Ok(*val), 7 | x => Err(ShellError::CantConvert( 8 | "f64".into(), 9 | x.get_type().to_string(), 10 | self.span()?, 11 | )), 12 | } 13 | } 14 | 15 | pub fn as_i64(&self) -> Result { 16 | match self { 17 | Value::Int { val, .. } => Ok(*val), 18 | x => Err(ShellError::CantConvert( 19 | "rf64".into(), 20 | x.get_type().to_string(), 21 | self.span()?, 22 | )), 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/nu-protocol/src/value/unit.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Clone, Copy)] 2 | pub enum Unit { 3 | // Filesize units: metric 4 | Byte, 5 | Kilobyte, 6 | Megabyte, 7 | Gigabyte, 8 | Terabyte, 9 | Petabyte, 10 | 11 | // Filesize units: ISO/IEC 80000 12 | Kibibyte, 13 | Mebibyte, 14 | Gibibyte, 15 | Tebibyte, 16 | Pebibyte, 17 | 18 | // Duration units 19 | Nanosecond, 20 | Microsecond, 21 | Millisecond, 22 | Second, 23 | Minute, 24 | Hour, 25 | Day, 26 | Week, 27 | } 28 | -------------------------------------------------------------------------------- /crates/nu-protocol/tests/test_value.rs: -------------------------------------------------------------------------------- 1 | use nu_protocol::{Span, Value}; 2 | 3 | #[test] 4 | fn test_comparison_nothing() { 5 | let values = vec![ 6 | Value::Int { 7 | val: 1, 8 | span: Span::test_data(), 9 | }, 10 | Value::String { 11 | val: "string".into(), 12 | span: Span::test_data(), 13 | }, 14 | Value::Float { 15 | val: 1.0, 16 | span: Span::test_data(), 17 | }, 18 | ]; 19 | 20 | let nothing = Value::Nothing { 21 | span: Span::test_data(), 22 | }; 23 | 24 | for value in values { 25 | assert!(matches!( 26 | value.eq(Span::test_data(), ¬hing), 27 | Ok(Value::Bool { val: false, .. }) 28 | )); 29 | 30 | assert!(matches!( 31 | value.ne(Span::test_data(), ¬hing), 32 | Ok(Value::Bool { val: true, .. }) 33 | )); 34 | 35 | assert!(matches!( 36 | nothing.eq(Span::test_data(), &value), 37 | Ok(Value::Bool { val: false, .. }) 38 | )); 39 | 40 | assert!(matches!( 41 | nothing.ne(Span::test_data(), &value), 42 | Ok(Value::Bool { val: true, .. }) 43 | )); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /crates/nu-system/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /crates/nu-system/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors", "procs creators"] 3 | description = "Nushell system querying" 4 | name = "nu-system" 5 | version = "0.60.0" 6 | edition = "2021" 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [[bin]] 11 | name = "ps" 12 | path = "src/main.rs" 13 | 14 | [dependencies] 15 | 16 | 17 | [target.'cfg(target_os = "linux")'.dependencies] 18 | procfs = "0.12.0" 19 | users = "0.11" 20 | which = "4" 21 | 22 | [target.'cfg(target_os = "macos")'.dependencies] 23 | libproc = "0.10" 24 | errno = "0.2" 25 | users = "0.11" 26 | which = "4" 27 | libc = "0.2" 28 | 29 | [target.'cfg(target_os = "windows")'.dependencies] 30 | # winapi = { version = "0.3", features = ["handleapi", "minwindef", "psapi", "securitybaseapi", "tlhelp32", "winbase", "winnt"] } 31 | winapi = { version = "0.3.9", features = ["tlhelp32", "fileapi", "handleapi", "ifdef", "ioapiset", "minwindef", "pdh", "psapi", "synchapi", "sysinfoapi", "winbase", "winerror", "winioctl", "winnt", "oleauto", "wbemcli", "rpcdce", "combaseapi", "objidl", "powerbase", "netioapi", "lmcons", "lmaccess", "lmapibuf", "memoryapi", "shellapi", "std"] } 32 | chrono = "0.4" 33 | libc = "0.2" 34 | ntapi = "0.3" 35 | once_cell = "1.0" -------------------------------------------------------------------------------- /crates/nu-system/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 procs developers and Nushell developers 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 | -------------------------------------------------------------------------------- /crates/nu-system/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(target_os = "linux")] 2 | mod linux; 3 | #[cfg(target_os = "macos")] 4 | mod macos; 5 | #[cfg(target_os = "windows")] 6 | mod windows; 7 | 8 | #[cfg(target_os = "linux")] 9 | pub use self::linux::*; 10 | #[cfg(target_os = "macos")] 11 | pub use self::macos::*; 12 | #[cfg(target_os = "windows")] 13 | pub use self::windows::*; 14 | -------------------------------------------------------------------------------- /crates/nu-system/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::time::Duration; 2 | 3 | fn main() { 4 | for proc in nu_system::collect_proc(Duration::from_millis(100), false) { 5 | // if proc.cpu_usage() > 0.1 { 6 | println!( 7 | "{} - {} - {} - {:.1} - {}M - {}M", 8 | proc.pid(), 9 | proc.name(), 10 | proc.status(), 11 | proc.cpu_usage(), 12 | proc.mem_size() / (1024 * 1024), 13 | proc.virtual_size() / (1024 * 1024), 14 | ) 15 | // } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/nu-table/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /scratch 3 | **/*.rs.bk 4 | history.txt 5 | tests/fixtures/nuplayground 6 | crates/*/target 7 | 8 | # Debian/Ubuntu 9 | debian/.debhelper/ 10 | debian/debhelper-build-stamp 11 | debian/files 12 | debian/nu.substvars 13 | debian/nu/ 14 | 15 | # macOS junk 16 | .DS_Store 17 | 18 | # JetBrains' IDE items 19 | .idea/* 20 | 21 | # VSCode's IDE items 22 | .vscode/* 23 | -------------------------------------------------------------------------------- /crates/nu-table/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "Nushell table printing" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu-table" 7 | version = "0.36.0" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [[bin]] 11 | name = "table" 12 | path = "src/main.rs" 13 | 14 | [dependencies] 15 | # nu-ansi-term = { path = "../nu-ansi-term" } 16 | nu-ansi-term = "0.42.0" 17 | nu-protocol = { path = "../nu-protocol"} 18 | regex = "1.4" 19 | unicode-width = "0.1.8" 20 | strip-ansi-escapes = "0.1.1" 21 | ansi-cut = "0.2.0" 22 | atty = "0.2.14" 23 | -------------------------------------------------------------------------------- /crates/nu-table/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod table; 2 | mod wrap; 3 | 4 | pub use table::{draw_table, StyledString, Table, TextStyle, Theme}; 5 | pub use wrap::Alignment; 6 | -------------------------------------------------------------------------------- /crates/nu-term-grid/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /scratch 3 | **/*.rs.bk 4 | history.txt 5 | tests/fixtures/nuplayground 6 | crates/*/target 7 | 8 | # Debian/Ubuntu 9 | debian/.debhelper/ 10 | debian/debhelper-build-stamp 11 | debian/files 12 | debian/nu.substvars 13 | debian/nu/ 14 | 15 | # macOS junk 16 | .DS_Store 17 | 18 | # JetBrains' IDE items 19 | .idea/* 20 | 21 | # VSCode's IDE items 22 | .vscode/* 23 | -------------------------------------------------------------------------------- /crates/nu-term-grid/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "Nushell grid printing" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu-term-grid" 7 | version = "0.36.0" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [[bin]] 11 | name = "grid" 12 | path = "src/main.rs" 13 | 14 | [dependencies] 15 | unicode-width = "0.1.9" 16 | strip-ansi-escapes = "0.1.1" 17 | -------------------------------------------------------------------------------- /crates/nu-term-grid/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod grid; 2 | 3 | pub use grid::Grid; 4 | -------------------------------------------------------------------------------- /crates/nu-term-grid/src/main.rs: -------------------------------------------------------------------------------- 1 | use nu_term_grid::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions}; 2 | 3 | // This produces: 4 | // 5 | // 1 | 128 | 16384 | 2097152 | 268435456 | 34359738368 | 4398046511104 6 | // 2 | 256 | 32768 | 4194304 | 536870912 | 68719476736 | 8796093022208 7 | // 4 | 512 | 65536 | 8388608 | 1073741824 | 137438953472 | 17592186044416 8 | // 8 | 1024 | 131072 | 16777216 | 2147483648 | 274877906944 | 35184372088832 9 | // 16 | 2048 | 262144 | 33554432 | 4294967296 | 549755813888 | 70368744177664 10 | // 32 | 4096 | 524288 | 67108864 | 8589934592 | 1099511627776 | 140737488355328 11 | // 64 | 8192 | 1048576 | 134217728 | 17179869184 | 2199023255552 | 12 | 13 | fn main() { 14 | let mut grid = Grid::new(GridOptions { 15 | direction: Direction::TopToBottom, 16 | filling: Filling::Text(" | ".into()), 17 | }); 18 | 19 | for i in 0..48 { 20 | let mut cell = Cell::from(format!("{}", 2_isize.pow(i))); 21 | cell.alignment = Alignment::Right; 22 | grid.add(cell) 23 | } 24 | 25 | if let Some(grid_display) = grid.fit_into_width(80) { 26 | println!("{}", grid_display); 27 | } else { 28 | println!("Couldn't fit grid into 80 columns!"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /crates/nu-test-support/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "Support for writing Nushell tests" 4 | edition = "2018" 5 | license = "MIT" 6 | name = "nu-test-support" 7 | version = "0.43.0" 8 | 9 | [lib] 10 | doctest = false 11 | 12 | [dependencies] 13 | nu-path = { path="../nu-path" } 14 | nu-protocol = { path="../nu-protocol" } 15 | 16 | bigdecimal = { package = "bigdecimal", version = "0.3.0", features = ["serde"] } 17 | chrono = "0.4.19" 18 | getset = "0.1.1" 19 | glob = "0.3.0" 20 | indexmap = { version="1.6.1", features=["serde-1"] } 21 | num-bigint = { version="0.4.3", features=["serde"] } 22 | tempfile = "3.2.0" 23 | hamcrest2 = "0.3.0" 24 | -------------------------------------------------------------------------------- /crates/nu-test-support/src/commands.rs: -------------------------------------------------------------------------------- 1 | // use nu_protocol::{ 2 | // ast::{Expr, Expression}, 3 | // Span, Spanned, Type, 4 | // }; 5 | 6 | // pub struct ExternalBuilder { 7 | // name: String, 8 | // args: Vec, 9 | // } 10 | 11 | // impl ExternalBuilder { 12 | // pub fn for_name(name: &str) -> ExternalBuilder { 13 | // ExternalBuilder { 14 | // name: name.to_string(), 15 | // args: vec![], 16 | // } 17 | // } 18 | 19 | // pub fn arg(&mut self, value: &str) -> &mut Self { 20 | // self.args.push(value.to_string()); 21 | // self 22 | // } 23 | 24 | // pub fn build(&mut self) -> ExternalCommand { 25 | // let mut path = crate::fs::binaries(); 26 | // path.push(&self.name); 27 | 28 | // let name = Spanned { 29 | // item: path.to_string_lossy().to_string(), 30 | // span: Span::new(0, 0), 31 | // }; 32 | 33 | // let args = self 34 | // .args 35 | // .iter() 36 | // .map(|arg| Expression { 37 | // expr: Expr::String(arg.to_string()), 38 | // span: Span::new(0, 0), 39 | // ty: Type::Unknown, 40 | // custom_completion: None, 41 | // }) 42 | // .collect::>(); 43 | 44 | // ExternalCommand { 45 | // name: name.to_string(), 46 | // name_tag: Tag::unknown(), 47 | // args: ExternalArgs { 48 | // list: args, 49 | // span: name.span, 50 | // }, 51 | // } 52 | // } 53 | // } 54 | -------------------------------------------------------------------------------- /crates/nu-test-support/src/playground.rs: -------------------------------------------------------------------------------- 1 | mod director; 2 | pub mod matchers; 3 | pub mod nu_process; 4 | mod play; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | 9 | pub use director::Director; 10 | pub use matchers::says; 11 | pub use nu_process::{Executable, NuProcess, NuResult, Outcome}; 12 | pub use play::{Dirs, EnvironmentVariable, Playground}; 13 | -------------------------------------------------------------------------------- /crates/nu-test-support/src/playground/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::playground::Playground; 2 | use std::path::{Path, PathBuf}; 3 | 4 | fn path(p: &Path) -> PathBuf { 5 | let cwd = std::env::current_dir().expect("Could not get current working directory."); 6 | nu_path::canonicalize_with(p, cwd) 7 | .unwrap_or_else(|e| panic!("Couldn't canonicalize path {}: {:?}", p.display(), e)) 8 | } 9 | 10 | #[test] 11 | fn current_working_directory_in_sandbox_directory_created() { 12 | Playground::setup("topic", |dirs, nu| { 13 | let original_cwd = dirs.test(); 14 | nu.within("some_directory_within"); 15 | 16 | assert_eq!(path(nu.cwd()), original_cwd.join("some_directory_within")); 17 | }) 18 | } 19 | 20 | #[test] 21 | fn current_working_directory_back_to_root_from_anywhere() { 22 | Playground::setup("topic", |dirs, nu| { 23 | let original_cwd = dirs.test(); 24 | 25 | nu.within("some_directory_within"); 26 | nu.back_to_playground(); 27 | 28 | assert_eq!(path(nu.cwd()), *original_cwd); 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /crates/nu_plugin_example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "A version incrementer plugin for Nushell" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu_plugin_example" 7 | version = "0.1.0" 8 | 9 | [dependencies] 10 | nu-plugin = { path="../nu-plugin", version = "0.1.0" } 11 | nu-protocol = { path="../nu-protocol", version = "0.1.0", features = ["plugin"]} 12 | -------------------------------------------------------------------------------- /crates/nu_plugin_example/README.md: -------------------------------------------------------------------------------- 1 | # Plugin Example 2 | 3 | Crate with a simple example of the Plugin trait that needs to be implemented 4 | in order to create a binary that can be registered into nushell declaration list 5 | -------------------------------------------------------------------------------- /crates/nu_plugin_example/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod example; 2 | mod nu; 3 | 4 | pub use example::Example; 5 | -------------------------------------------------------------------------------- /crates/nu_plugin_gstat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "A git status plugin for Nushell" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu_plugin_gstat" 7 | version = "0.1.0" 8 | 9 | [lib] 10 | doctest = false 11 | 12 | [dependencies] 13 | nu-plugin = { path="../nu-plugin", version = "0.1.0" } 14 | nu-protocol = { path="../nu-protocol", version = "0.1.0" } 15 | nu-engine = { path="../nu-engine", version = "0.1.0" } 16 | 17 | git2 = "0.13.24" 18 | -------------------------------------------------------------------------------- /crates/nu_plugin_gstat/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod gstat; 2 | mod nu; 3 | 4 | pub use gstat::GStat; 5 | -------------------------------------------------------------------------------- /crates/nu_plugin_gstat/src/main.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_gstat::GStat; 3 | 4 | fn main() { 5 | serve_plugin(&mut GStat::new(), CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /crates/nu_plugin_gstat/src/nu/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::GStat; 2 | use nu_plugin::{EvaluatedCall, LabeledError, Plugin}; 3 | use nu_protocol::{Category, Signature, Spanned, SyntaxShape, Value}; 4 | 5 | impl Plugin for GStat { 6 | fn signature(&self) -> Vec { 7 | vec![Signature::build("gstat") 8 | .desc("Get the git status of a repo") 9 | .optional("path", SyntaxShape::String, "path to repo") 10 | .category(Category::Custom("Prompt".to_string()))] 11 | } 12 | 13 | fn run( 14 | &mut self, 15 | name: &str, 16 | call: &EvaluatedCall, 17 | input: &Value, 18 | ) -> Result { 19 | if name != "gstat" { 20 | return Ok(Value::Nothing { span: call.head }); 21 | } 22 | 23 | let repo_path: Option> = call.opt(0)?; 24 | // eprintln!("input value: {:#?}", &input); 25 | self.gstat(input, repo_path, &call.head) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/nu_plugin_inc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "A version incrementer plugin for Nushell" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu_plugin_inc" 7 | version = "0.1.0" 8 | 9 | [lib] 10 | doctest = false 11 | 12 | [dependencies] 13 | nu-plugin = { path="../nu-plugin", version = "0.1.0" } 14 | nu-protocol = { path="../nu-protocol", version = "0.1.0", features = ["plugin"]} 15 | 16 | semver = "0.11.0" 17 | -------------------------------------------------------------------------------- /crates/nu_plugin_inc/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod inc; 2 | mod nu; 3 | 4 | pub use inc::Inc; 5 | -------------------------------------------------------------------------------- /crates/nu_plugin_inc/src/main.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_inc::Inc; 3 | 4 | fn main() { 5 | serve_plugin(&mut Inc::new(), CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /crates/nu_plugin_inc/src/nu/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::inc::SemVerAction; 2 | use crate::Inc; 3 | use nu_plugin::{EvaluatedCall, LabeledError, Plugin}; 4 | use nu_protocol::{Signature, Value}; 5 | 6 | impl Plugin for Inc { 7 | fn signature(&self) -> Vec { 8 | vec![Signature::build("inc") 9 | .desc("Increment a value or version. Optionally use the column of a table.") 10 | .switch( 11 | "major", 12 | "increment the major version (eg 1.2.1 -> 2.0.0)", 13 | Some('M'), 14 | ) 15 | .switch( 16 | "minor", 17 | "increment the minor version (eg 1.2.1 -> 1.3.0)", 18 | Some('m'), 19 | ) 20 | .switch( 21 | "patch", 22 | "increment the patch version (eg 1.2.1 -> 1.2.2)", 23 | Some('p'), 24 | )] 25 | } 26 | 27 | fn run( 28 | &mut self, 29 | name: &str, 30 | call: &EvaluatedCall, 31 | input: &Value, 32 | ) -> Result { 33 | if name != "inc" { 34 | return Ok(Value::Nothing { span: call.head }); 35 | } 36 | 37 | if call.has_flag("major") { 38 | self.for_semver(SemVerAction::Major); 39 | } 40 | if call.has_flag("minor") { 41 | self.for_semver(SemVerAction::Minor); 42 | } 43 | if call.has_flag("patch") { 44 | self.for_semver(SemVerAction::Patch); 45 | } 46 | 47 | self.inc(call.head, input) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /crates/nu_plugin_query/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["The Nu Project Contributors"] 3 | description = "A set of query commands for Nushell" 4 | edition = "2021" 5 | license = "MIT" 6 | name = "nu_plugin_query" 7 | version = "0.1.0" 8 | 9 | [lib] 10 | doctest = false 11 | 12 | [dependencies] 13 | nu-plugin = { path="../nu-plugin", version = "0.1.0" } 14 | nu-protocol = { path="../nu-protocol", version = "0.1.0" } 15 | nu-engine = { path="../nu-engine", version = "0.1.0" } 16 | gjson = "0.8.0" 17 | scraper = "0.12.0" 18 | sxd-document = "0.3.2" 19 | sxd-xpath = "0.4.2" 20 | -------------------------------------------------------------------------------- /crates/nu_plugin_query/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod nu; 2 | mod query; 3 | mod query_json; 4 | mod query_web; 5 | mod query_xml; 6 | mod web_tables; 7 | 8 | pub use query::Query; 9 | pub use query_json::execute_json_query; 10 | pub use query_web::parse_selector_params; 11 | pub use query_xml::execute_xpath_query; 12 | pub use web_tables::WebTable; 13 | -------------------------------------------------------------------------------- /crates/nu_plugin_query/src/main.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_query::Query; 3 | 4 | fn main() { 5 | serve_plugin(&mut Query {}, CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /docs/3rd_Party_Prompts.md: -------------------------------------------------------------------------------- 1 | # How to configure 3rd party prompts 2 | 3 | ## nerdfonts 4 | 5 | nerdfonts are not required but they make the presentation much better. 6 | 7 | [site](https://www.nerdfonts.com) 8 | 9 | [repo](https://github.com/ryanoasis/nerd-fonts) 10 | 11 | 12 | ## oh-my-posh 13 | 14 | [site](ttps://ohmyposh.dev/) 15 | 16 | [repo](https://github.com/JanDeDobbeleer/oh-my-posh) 17 | 18 | 19 | If you like [oh-my-posh](https://ohmyposh.dev/), you can use oh-my-posh with engine-q with few steps. It's works great with engine-q. There is how to setup oh-my-posh with engine-q: 20 | 21 | 1. Install Oh My Posh and download oh-my-posh's themes following [guide](https://ohmyposh.dev/docs/linux#installation) 22 | 2. Download and Install a [nerd font](https://github.com/ryanoasis/nerd-fonts) 23 | 3. Set the PROMPT_COMMAND in ~/.config/nushell/config.nu, change `M365Princess.omp.json` to whatever you like [Themes demo](https://ohmyposh.dev/docs/themes) 24 | ``` 25 | let-env PROMPT_COMMAND = { oh-my-posh --config ~/.poshthemes/M365Princess.omp.json } 26 | ``` 27 | 4. Restart engine-q. 28 | 29 | ## Starship 30 | 31 | [site](https://starship.rs/) 32 | 33 | [repo](https://github.com/starship/starship) 34 | 35 | ## Purs 36 | 37 | [repo](https://github.com/xcambar/purs) 38 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | Here is a collection of various pages documenting the changes made in engine-q which should probably end up in the book after we merge it to Nushell. 4 | -------------------------------------------------------------------------------- /src/plugins/nu_plugin_core_example.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_example::Example; 3 | 4 | fn main() { 5 | serve_plugin(&mut Example {}, CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /src/plugins/nu_plugin_core_inc.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_inc::Inc; 3 | 4 | fn main() { 5 | serve_plugin(&mut Inc::new(), CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /src/plugins/nu_plugin_extra_gstat.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_gstat::GStat; 3 | 4 | fn main() { 5 | serve_plugin(&mut GStat::new(), CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /src/plugins/nu_plugin_extra_query.rs: -------------------------------------------------------------------------------- 1 | use nu_plugin::{serve_plugin, CapnpSerializer}; 2 | use nu_plugin_query::Query; 3 | 4 | fn main() { 5 | serve_plugin(&mut Query::new(), CapnpSerializer {}) 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/test_conditionals.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{run_test, TestResult}; 2 | 3 | #[test] 4 | fn if_test1() -> TestResult { 5 | run_test("if $true { 10 } else { 20 } ", "10") 6 | } 7 | 8 | #[test] 9 | fn if_test2() -> TestResult { 10 | run_test("if $false { 10 } else { 20 } ", "20") 11 | } 12 | 13 | #[test] 14 | fn simple_if() -> TestResult { 15 | run_test("if $true { 10 } ", "10") 16 | } 17 | 18 | #[test] 19 | fn simple_if2() -> TestResult { 20 | run_test("if $false { 10 } ", "") 21 | } 22 | 23 | #[test] 24 | fn if_cond() -> TestResult { 25 | run_test("if 2 < 3 { 3 } ", "3") 26 | } 27 | 28 | #[test] 29 | fn if_cond2() -> TestResult { 30 | run_test("if 2 > 3 { 3 } ", "") 31 | } 32 | 33 | #[test] 34 | fn if_cond3() -> TestResult { 35 | run_test("if 2 < 3 { 5 } else { 4 } ", "5") 36 | } 37 | 38 | #[test] 39 | fn if_cond4() -> TestResult { 40 | run_test("if 2 > 3 { 5 } else { 4 } ", "4") 41 | } 42 | 43 | #[test] 44 | fn if_elseif1() -> TestResult { 45 | run_test("if 2 > 3 { 5 } else if 6 < 7 { 4 } ", "4") 46 | } 47 | 48 | #[test] 49 | fn if_elseif2() -> TestResult { 50 | run_test("if 2 < 3 { 5 } else if 6 < 7 { 4 } else { 8 } ", "5") 51 | } 52 | 53 | #[test] 54 | fn if_elseif3() -> TestResult { 55 | run_test("if 2 > 3 { 5 } else if 6 > 7 { 4 } else { 8 } ", "8") 56 | } 57 | 58 | #[test] 59 | fn if_elseif4() -> TestResult { 60 | run_test("if 2 > 3 { 5 } else if 6 < 7 { 4 } else { 8 } ", "4") 61 | } 62 | -------------------------------------------------------------------------------- /src/tests/test_converters.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{run_test, TestResult}; 2 | 3 | #[test] 4 | fn from_json_1() -> TestResult { 5 | run_test(r#"('{"name": "Fred"}' | from json).name"#, "Fred") 6 | } 7 | 8 | #[test] 9 | fn from_json_2() -> TestResult { 10 | run_test( 11 | r#"('{"name": "Fred"} 12 | {"name": "Sally"}' | from json -o).name.1"#, 13 | "Sally", 14 | ) 15 | } 16 | 17 | #[test] 18 | fn to_json_raw_flag_1() -> TestResult { 19 | run_test( 20 | "[[a b]; [jim susie] [3 4]] | to json -r", 21 | r#"[{"a": "jim","b": "susie"},{"a": 3,"b": 4}]"#, 22 | ) 23 | } 24 | 25 | #[test] 26 | fn to_json_raw_flag_2() -> TestResult { 27 | run_test( 28 | "[[\"a b\" c]; [jim susie] [3 4]] | to json -r", 29 | r#"[{"a b": "jim","c": "susie"},{"a b": 3,"c": 4}]"#, 30 | ) 31 | } 32 | 33 | #[test] 34 | fn to_json_raw_flag_3() -> TestResult { 35 | run_test( 36 | "[[\"a b\" \"c d\"]; [\"jim smith\" \"susie roberts\"] [3 4]] | to json -r", 37 | r#"[{"a b": "jim smith","c d": "susie roberts"},{"a b": 3,"c d": 4}]"#, 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/test_env.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{run_test, TestResult}; 2 | 3 | #[test] 4 | fn shorthand_env_1() -> TestResult { 5 | run_test(r#"FOO=BAZ $env.FOO"#, "BAZ") 6 | } 7 | 8 | #[test] 9 | fn shorthand_env_2() -> TestResult { 10 | run_test(r#"FOO=BAZ FOO=MOO $env.FOO"#, "MOO") 11 | } 12 | 13 | #[test] 14 | fn shorthand_env_3() -> TestResult { 15 | run_test(r#"FOO=BAZ BAR=MOO $env.FOO"#, "BAZ") 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/test_iteration.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{run_test, TestResult}; 2 | 3 | #[test] 4 | fn better_block_types() -> TestResult { 5 | run_test( 6 | r#"([1, 2, 3] | each -n { $"($it.index) is ($it.item)" }).1"#, 7 | "1 is 2", 8 | ) 9 | } 10 | 11 | #[test] 12 | fn row_iteration() -> TestResult { 13 | run_test( 14 | "[[name, size]; [tj, 100], [rl, 200]] | each { $it.size * 8 } | get 1", 15 | "1600", 16 | ) 17 | } 18 | 19 | #[test] 20 | fn record_iteration() -> TestResult { 21 | run_test("([[name, level]; [aa, 100], [bb, 200]] | each { $it | each { |x| if $x.column == \"level\" { $x.value + 100 } else { $x.value } } }).level | get 1", "300") 22 | } 23 | 24 | #[test] 25 | fn row_condition1() -> TestResult { 26 | run_test( 27 | "([[name, size]; [a, 1], [b, 2], [c, 3]] | where size < 3).name | get 1", 28 | "b", 29 | ) 30 | } 31 | 32 | #[test] 33 | fn row_condition2() -> TestResult { 34 | run_test( 35 | "[[name, size]; [a, 1], [b, 2], [c, 3]] | where $it.size > 2 | length", 36 | "1", 37 | ) 38 | } 39 | 40 | #[test] 41 | fn for_loops() -> TestResult { 42 | run_test(r#"(for x in [1, 2, 3] { $x + 10 }).1"#, "12") 43 | } 44 | 45 | #[test] 46 | fn par_each() -> TestResult { 47 | run_test( 48 | r#"1..10 | par-each --numbered { ([[index, item]; [$it.index, ($it.item > 5)]]).0 } | where index == 4 | get item.0"#, 49 | "false", 50 | ) 51 | } 52 | -------------------------------------------------------------------------------- /src/tests/test_math.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{fail_test, run_test, TestResult}; 2 | 3 | #[test] 4 | fn add_simple() -> TestResult { 5 | run_test("3 + 4", "7") 6 | } 7 | 8 | #[test] 9 | fn add_simple2() -> TestResult { 10 | run_test("3 + 4 + 9", "16") 11 | } 12 | 13 | #[test] 14 | fn broken_math() -> TestResult { 15 | fail_test("3 + ", "incomplete") 16 | } 17 | 18 | #[test] 19 | fn modulo1() -> TestResult { 20 | run_test("5 mod 2", "1") 21 | } 22 | 23 | #[test] 24 | fn modulo2() -> TestResult { 25 | run_test("5.25 mod 2", "1.25") 26 | } 27 | 28 | #[test] 29 | fn and() -> TestResult { 30 | run_test("$true && $false", "false") 31 | } 32 | 33 | #[test] 34 | fn or() -> TestResult { 35 | run_test("$true || $false", "true") 36 | } 37 | 38 | #[test] 39 | fn pow() -> TestResult { 40 | run_test("3 ** 3", "27") 41 | } 42 | 43 | #[test] 44 | fn contains() -> TestResult { 45 | run_test("'testme' =~ 'test'", "true") 46 | } 47 | 48 | #[test] 49 | fn not_contains() -> TestResult { 50 | run_test("'testme' !~ 'test'", "false") 51 | } 52 | 53 | #[test] 54 | fn floating_add() -> TestResult { 55 | run_test("10.1 + 0.8", "10.9") 56 | } 57 | 58 | #[test] 59 | fn precedence_of_or_groups() -> TestResult { 60 | run_test(r#"4 mod 3 == 0 || 5 mod 5 == 0"#, "true") 61 | } 62 | -------------------------------------------------------------------------------- /src/tests/test_ranges.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{fail_test, run_test, TestResult}; 2 | 3 | #[test] 4 | fn int_in_inc_range() -> TestResult { 5 | run_test(r#"1 in -4..9.42"#, "true") 6 | } 7 | 8 | #[test] 9 | fn int_in_dec_range() -> TestResult { 10 | run_test(r#"1 in 9.42..-4"#, "true") 11 | } 12 | 13 | #[test] 14 | fn int_in_exclusive_range() -> TestResult { 15 | run_test(r#"3 in 0..<3"#, "false") 16 | } 17 | 18 | #[test] 19 | fn non_number_in_range() -> TestResult { 20 | fail_test(r#"'a' in 1..3"#, "mismatched for operation") 21 | } 22 | 23 | #[test] 24 | fn float_not_in_inc_range() -> TestResult { 25 | run_test(r#"1.4 not-in 2..9.42"#, "true") 26 | } 27 | 28 | #[test] 29 | fn range_and_reduction() -> TestResult { 30 | run_test(r#"1..6..36 | math sum"#, "148") 31 | } 32 | 33 | #[test] 34 | fn zip_ranges() -> TestResult { 35 | run_test(r#"1..3 | zip 4..6 | get 2.1"#, "6") 36 | } 37 | -------------------------------------------------------------------------------- /src/tests/test_type_check.rs: -------------------------------------------------------------------------------- 1 | use crate::tests::{fail_test, run_test, TestResult}; 2 | 3 | #[test] 4 | fn chained_operator_typecheck() -> TestResult { 5 | run_test("1 != 2 && 3 != 4 && 5 != 6", "true") 6 | } 7 | 8 | #[test] 9 | fn type_in_list_of_this_type() -> TestResult { 10 | run_test(r#"42 in [41 42 43]"#, "true") 11 | } 12 | 13 | #[test] 14 | fn type_in_list_of_non_this_type() -> TestResult { 15 | fail_test(r#"'hello' in [41 42 43]"#, "mismatched for operation") 16 | } 17 | 18 | #[test] 19 | fn number_int() -> TestResult { 20 | run_test(r#"def foo [x:number] { $x }; foo 1"#, "1") 21 | } 22 | 23 | #[test] 24 | fn number_float() -> TestResult { 25 | run_test(r#"def foo [x:number] { $x }; foo 1.4"#, "1.4") 26 | } 27 | -------------------------------------------------------------------------------- /tests/assets/nu_json/charset_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | ql-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 3 | js-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 4 | ml-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 5 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/charset_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "ql-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 3 | "js-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", 4 | "ml-ascii": "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 5 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/charset_test.hjson: -------------------------------------------------------------------------------- 1 | ql-ascii: ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 2 | js-ascii: "! \"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 3 | ml-ascii: 4 | ''' 5 | ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 6 | ''' 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/comments_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | foo1: This is a string value. # part of the string 3 | foo2: This is a string value. 4 | bar1: This is a string value. // part of the string 5 | bar2: This is a string value. 6 | foobar1: This is a string value./* part of the string */ 7 | foobar2: This is a string value. 8 | rem1: "# test" 9 | rem2: "// test" 10 | rem3: "/* test */" 11 | num1: 0 12 | num2: 0 13 | num3: 2 14 | true1: true 15 | true2: true 16 | true3: true 17 | false1: false 18 | false2: false 19 | false3: false 20 | null1: null 21 | null2: null 22 | null3: null 23 | str1: 00 # part of the string 24 | str2: 00.0 // part of the string 25 | str3: 02 /* part of the string */ 26 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/comments_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo1": "This is a string value. # part of the string", 3 | "foo2": "This is a string value.", 4 | "bar1": "This is a string value. // part of the string", 5 | "bar2": "This is a string value.", 6 | "foobar1": "This is a string value./* part of the string */", 7 | "foobar2": "This is a string value.", 8 | "rem1": "# test", 9 | "rem2": "// test", 10 | "rem3": "/* test */", 11 | "num1": 0, 12 | "num2": 0, 13 | "num3": 2, 14 | "true1": true, 15 | "true2": true, 16 | "true3": true, 17 | "false1": false, 18 | "false2": false, 19 | "false3": false, 20 | "null1": null, 21 | "null2": null, 22 | "null3": null, 23 | "str1": "00 # part of the string", 24 | "str2": "00.0 // part of the string", 25 | "str3": "02 /* part of the string */" 26 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/comments_test.hjson: -------------------------------------------------------------------------------- 1 | // test 2 | # all 3 | // comment 4 | /* 5 | styles 6 | */ 7 | # with lf 8 | 9 | 10 | 11 | # ! 12 | 13 | { 14 | # hjson style comment 15 | foo1: This is a string value. # part of the string 16 | foo2: "This is a string value." # a comment 17 | 18 | // js style comment 19 | bar1: This is a string value. // part of the string 20 | bar2: "This is a string value." // a comment 21 | 22 | /* js block style comments */foobar1:/* more */This is a string value./* part of the string */ 23 | /* js block style comments */foobar2:/* more */"This is a string value."/* a comment */ 24 | 25 | rem1: "# test" 26 | rem2: "// test" 27 | rem3: "/* test */" 28 | 29 | num1: 0 # comment 30 | num2: 0.0 // comment 31 | num3: 2 /* comment */ 32 | 33 | true1: true # comment 34 | true2: true // comment 35 | true3: true /* comment */ 36 | 37 | false1: false # comment 38 | false2: false // comment 39 | false3: false /* comment */ 40 | 41 | null1: null # comment 42 | null2: null // comment 43 | null3: null /* comment */ 44 | 45 | str1: 00 # part of the string 46 | str2: 00.0 // part of the string 47 | str3: 02 /* part of the string */ 48 | } 49 | -------------------------------------------------------------------------------- /tests/assets/nu_json/empty_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | "": empty 3 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/empty_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "": "empty" 3 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/empty_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | "": empty 3 | } 4 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failCharset1_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid \u char 3 | char: "\uxxxx" 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON02_test.json: -------------------------------------------------------------------------------- 1 | ["Unclosed array" -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON05_test.json: -------------------------------------------------------------------------------- 1 | ["double extra comma",,] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON06_test.json: -------------------------------------------------------------------------------- 1 | [ , "<-- missing value"] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON07_test.json: -------------------------------------------------------------------------------- 1 | ["Comma after the close"], -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON08_test.json: -------------------------------------------------------------------------------- 1 | ["Extra close"]] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON10_test.json: -------------------------------------------------------------------------------- 1 | {"Extra value after close": true} "misplaced quoted value" -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON11_test.json: -------------------------------------------------------------------------------- 1 | {"Illegal expression": 1 + 2} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON12_test.json: -------------------------------------------------------------------------------- 1 | {"Illegal invocation": alert()} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON13_test.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot have leading zeroes": 013} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON14_test.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot be hex": 0x14} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON15_test.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \x15"] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON16_test.json: -------------------------------------------------------------------------------- 1 | [\naked] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON17_test.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \017"] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON19_test.json: -------------------------------------------------------------------------------- 1 | {"Missing colon" null} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON20_test.json: -------------------------------------------------------------------------------- 1 | {"Double colon":: null} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON21_test.json: -------------------------------------------------------------------------------- 1 | {"Comma instead of colon", null} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON22_test.json: -------------------------------------------------------------------------------- 1 | ["Colon instead of comma": false] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON23_test.json: -------------------------------------------------------------------------------- 1 | ["Bad value", truth] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON24_test.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON26_test.json: -------------------------------------------------------------------------------- 1 | ["tab\ character\ in\ string\ "] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON28_test.json: -------------------------------------------------------------------------------- 1 | ["line\ 2 | break"] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON29_test.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON30_test.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON31_test.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON32_test.json: -------------------------------------------------------------------------------- 1 | {"Comma instead if closing brace": true, -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON33_test.json: -------------------------------------------------------------------------------- 1 | ["mismatch"} -------------------------------------------------------------------------------- /tests/assets/nu_json/failJSON34_test.json: -------------------------------------------------------------------------------- 1 | A quoteless string is OK, 2 | but two must be contained in an array. 3 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failKey1_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid name 3 | wrong name: 0 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failKey2_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid name 3 | {name: 0 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failKey3_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid name 3 | key,name: 0 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failKey4_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid name 3 | : 0 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failMLStr1_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid multiline string 3 | ml: ''' 4 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failObj1_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid obj 3 | noDelimiter 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failObj2_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid obj 3 | noEnd 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failObj3_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # missing key 3 | 4 | [ 5 | test 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr1a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: ] 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr1b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: ]x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr1c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | ] 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr1d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | ]x 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr2a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: } 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr2b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: }x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr2c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | } 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr2d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | }x 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr3a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: { 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr3b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: {x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr3c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | { 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr3d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | {x 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr4a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: [ 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr4b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: [x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr4c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | [ 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr4d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | [x 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr5a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: : 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr5b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: :x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr5c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | : 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr5d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | foo 3 | # invalid quoteless string 4 | :x 5 | ] 6 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr6a_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: , 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr6b_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # invalid quoteless string 3 | ql: ,x 4 | } 5 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr6c_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | # invalid quoteless string 3 | # note that if there were a preceding value the comma would 4 | # be allowed/ignored as a separator/trailing comma 5 | , 6 | ] 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/failStr6d_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | # invalid quoteless string 3 | # note that if there were a preceding value the comma would 4 | # be allowed/ignored as a separator/trailing comma 5 | ,x 6 | ] 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/kan_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | numbers: 3 | [ 4 | 0 5 | 0 6 | 0 7 | 42 8 | 42.1 9 | -5 10 | -5.1 11 | 1701 12 | -1701 13 | 12.345 14 | -12.345 15 | ] 16 | native: 17 | [ 18 | true 19 | true 20 | false 21 | false 22 | null 23 | null 24 | ] 25 | strings: 26 | [ 27 | x 0 28 | .0 29 | 00 30 | 01 31 | 0 0 0 32 | 42 x 33 | 42.1 asdf 34 | 1.2.3 35 | -5 0 - 36 | -5.1 -- 37 | 17.01e2 + 38 | -17.01e2 : 39 | 12345e-3 @ 40 | -12345e-3 $ 41 | true true 42 | x true 43 | false false 44 | x false 45 | null null 46 | x null 47 | ] 48 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/kan_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "numbers": [ 3 | 0, 4 | 0, 5 | 0, 6 | 42, 7 | 42.1, 8 | -5, 9 | -5.1, 10 | 1701, 11 | -1701, 12 | 12.345, 13 | -12.345 14 | ], 15 | "native": [ 16 | true, 17 | true, 18 | false, 19 | false, 20 | null, 21 | null 22 | ], 23 | "strings": [ 24 | "x 0", 25 | ".0", 26 | "00", 27 | "01", 28 | "0 0 0", 29 | "42 x", 30 | "42.1 asdf", 31 | "1.2.3", 32 | "-5 0 -", 33 | "-5.1 --", 34 | "17.01e2 +", 35 | "-17.01e2 :", 36 | "12345e-3 @", 37 | "-12345e-3 $", 38 | "true true", 39 | "x true", 40 | "false false", 41 | "x false", 42 | "null null", 43 | "x null" 44 | ] 45 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/kan_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # the comma forces a whitespace check 3 | numbers: 4 | [ 5 | 0 6 | 0 , 7 | -0 8 | 42 , 9 | 42.1 , 10 | -5 11 | -5.1 12 | 17.01e2 13 | -17.01e2 14 | 12345e-3 , 15 | -12345e-3 , 16 | ] 17 | native: 18 | [ 19 | true , 20 | true 21 | false , 22 | false 23 | null , 24 | null 25 | ] 26 | strings: 27 | [ 28 | x 0 29 | .0 30 | 00 31 | 01 32 | 0 0 0 33 | 42 x 34 | 42.1 asdf 35 | 1.2.3 36 | -5 0 - 37 | -5.1 -- 38 | 17.01e2 + 39 | -17.01e2 : 40 | 12345e-3 @ 41 | -12345e-3 $ 42 | true true 43 | x true 44 | false false 45 | x false 46 | null null 47 | x null 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /tests/assets/nu_json/keys_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | unquoted_key: test 3 | _unquoted: test 4 | test-key: test 5 | -test: test 6 | .key: test 7 | trailing: test 8 | trailing2: test 9 | "#c1": test 10 | "foo#bar": test 11 | "//bar": test 12 | "foo//bar": test 13 | "/*foo*/": test 14 | "foo/*foo*/bar": test 15 | "/*": test 16 | "foo/*bar": test 17 | "\"": test 18 | "foo\"bar": test 19 | "'''": test 20 | "foo'''bar": test 21 | ":": test 22 | "foo:bar": test 23 | "{": test 24 | "foo{bar": test 25 | "}": test 26 | "foo}bar": test 27 | "[": test 28 | "foo[bar": test 29 | "]": test 30 | "foo]bar": test 31 | nl1: test 32 | nl2: test 33 | nl3: test 34 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/keys_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "unquoted_key": "test", 3 | "_unquoted": "test", 4 | "test-key": "test", 5 | "-test": "test", 6 | ".key": "test", 7 | "trailing": "test", 8 | "trailing2": "test", 9 | "#c1": "test", 10 | "foo#bar": "test", 11 | "//bar": "test", 12 | "foo//bar": "test", 13 | "/*foo*/": "test", 14 | "foo/*foo*/bar": "test", 15 | "/*": "test", 16 | "foo/*bar": "test", 17 | "\"": "test", 18 | "foo\"bar": "test", 19 | "'''": "test", 20 | "foo'''bar": "test", 21 | ":": "test", 22 | "foo:bar": "test", 23 | "{": "test", 24 | "foo{bar": "test", 25 | "}": "test", 26 | "foo}bar": "test", 27 | "[": "test", 28 | "foo[bar": "test", 29 | "]": "test", 30 | "foo]bar": "test", 31 | "nl1": "test", 32 | "nl2": "test", 33 | "nl3": "test" 34 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/keys_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # unquoted keys 3 | unquoted_key: test 4 | _unquoted: test 5 | test-key: test 6 | -test: test 7 | .key: test 8 | # trailing spaces in key names are ignored 9 | trailing : test 10 | trailing2 : test 11 | # comment char in key name 12 | "#c1": test 13 | "foo#bar": test 14 | "//bar": test 15 | "foo//bar": test 16 | "/*foo*/": test 17 | "foo/*foo*/bar": test 18 | "/*": test 19 | "foo/*bar": test 20 | # quotes in key name 21 | "\"": test 22 | "foo\"bar": test 23 | "'''": test 24 | "foo'''bar": test 25 | # control char in key name 26 | ":": test 27 | "foo:bar": test 28 | "{": test 29 | "foo{bar": test 30 | "}": test 31 | "foo}bar": test 32 | "[": test 33 | "foo[bar": test 34 | "]": test 35 | "foo]bar": test 36 | # newline 37 | nl1: 38 | test 39 | nl2 40 | : 41 | test 42 | 43 | nl3 44 | 45 | : 46 | 47 | test 48 | } 49 | -------------------------------------------------------------------------------- /tests/assets/nu_json/oa_result.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | a 3 | {} 4 | {} 5 | [] 6 | [] 7 | { 8 | b: 1 9 | c: [] 10 | d: {} 11 | } 12 | [] 13 | ] -------------------------------------------------------------------------------- /tests/assets/nu_json/oa_result.json: -------------------------------------------------------------------------------- 1 | [ 2 | "a", 3 | {}, 4 | {}, 5 | [], 6 | [], 7 | { 8 | "b": 1, 9 | "c": [], 10 | "d": {} 11 | }, 12 | [] 13 | ] -------------------------------------------------------------------------------- /tests/assets/nu_json/oa_test.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | a 3 | {} 4 | {} 5 | [] 6 | [] 7 | { 8 | b: 1 9 | c: [] 10 | d: {} 11 | } 12 | [] 13 | ] 14 | -------------------------------------------------------------------------------- /tests/assets/nu_json/pass1_result.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | JSON Test Pattern pass1 3 | { 4 | "object with 1 member": 5 | [ 6 | array with 1 element 7 | ] 8 | } 9 | {} 10 | [] 11 | -42 12 | true 13 | false 14 | null 15 | { 16 | integer: 1234567890 17 | real: -9876.54321 18 | e: 1.23456789e-13 19 | E: 1.23456789e+34 20 | -: 2.3456789012e+76 21 | zero: 0 22 | one: 1 23 | space: " " 24 | quote: '''"''' 25 | backslash: \ 26 | controls: "\b\f\n\r\t" 27 | slash: / & / 28 | alpha: abcdefghijklmnopqrstuvwyz 29 | ALPHA: ABCDEFGHIJKLMNOPQRSTUVWYZ 30 | digit: 0123456789 31 | 0123456789: digit 32 | special: `1~!@#$%^&*()_+-={':[,]}|;.? 33 | hex: ģ䕧覫췯ꯍ 34 | true: true 35 | false: false 36 | null: null 37 | array: [] 38 | object: {} 39 | address: 50 St. James Street 40 | url: http://www.JSON.org/ 41 | comment: "// /* */": " " 43 | " s p a c e d ": 44 | [ 45 | 1 46 | 2 47 | 3 48 | 4 49 | 5 50 | 6 51 | 7 52 | ] 53 | compact: 54 | [ 55 | 1 56 | 2 57 | 3 58 | 4 59 | 5 60 | 6 61 | 7 62 | ] 63 | jsontext: '''{"object with 1 member":["array with 1 element"]}''' 64 | quotes: " " %22 0x22 034 " 65 | "/\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?": A key can be any string 66 | } 67 | 0.5 68 | 98.6 69 | 99.44 70 | 1066 71 | 10 72 | 1 73 | 0.1 74 | 1 75 | 2 76 | 2 77 | rosebud 78 | ] -------------------------------------------------------------------------------- /tests/assets/nu_json/pass2_result.hjson: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | [ 4 | [ 5 | [ 6 | [ 7 | [ 8 | [ 9 | [ 10 | [ 11 | [ 12 | [ 13 | [ 14 | [ 15 | [ 16 | [ 17 | [ 18 | [ 19 | [ 20 | Not too deep 21 | ] 22 | ] 23 | ] 24 | ] 25 | ] 26 | ] 27 | ] 28 | ] 29 | ] 30 | ] 31 | ] 32 | ] 33 | ] 34 | ] 35 | ] 36 | ] 37 | ] 38 | ] 39 | ] -------------------------------------------------------------------------------- /tests/assets/nu_json/pass2_result.json: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | [ 4 | [ 5 | [ 6 | [ 7 | [ 8 | [ 9 | [ 10 | [ 11 | [ 12 | [ 13 | [ 14 | [ 15 | [ 16 | [ 17 | [ 18 | [ 19 | [ 20 | "Not too deep" 21 | ] 22 | ] 23 | ] 24 | ] 25 | ] 26 | ] 27 | ] 28 | ] 29 | ] 30 | ] 31 | ] 32 | ] 33 | ] 34 | ] 35 | ] 36 | ] 37 | ] 38 | ] 39 | ] -------------------------------------------------------------------------------- /tests/assets/nu_json/pass2_test.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /tests/assets/nu_json/pass3_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": 3 | { 4 | "The outermost value": must be an object or array. 5 | "In this test": It is an object. 6 | } 7 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/pass3_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": { 3 | "The outermost value": "must be an object or array.", 4 | "In this test": "It is an object." 5 | } 6 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/pass3_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": { 3 | "The outermost value": "must be an object or array.", 4 | "In this test": "It is an object." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/pass4_result.hjson: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /tests/assets/nu_json/pass4_result.json: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /tests/assets/nu_json/pass4_test.json: -------------------------------------------------------------------------------- 1 | 2 | 10 3 | -------------------------------------------------------------------------------- /tests/assets/nu_json/passSingle_result.hjson: -------------------------------------------------------------------------------- 1 | allow quoteless strings -------------------------------------------------------------------------------- /tests/assets/nu_json/passSingle_result.json: -------------------------------------------------------------------------------- 1 | "allow quoteless strings" -------------------------------------------------------------------------------- /tests/assets/nu_json/passSingle_test.hjson: -------------------------------------------------------------------------------- 1 | allow quoteless strings -------------------------------------------------------------------------------- /tests/assets/nu_json/root_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | database: 3 | { 4 | host: 127.0.0.1 5 | port: 555 6 | } 7 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/root_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "database": { 3 | "host": "127.0.0.1", 4 | "port": 555 5 | } 6 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/root_test.hjson: -------------------------------------------------------------------------------- 1 | // a object with the root braces omitted 2 | database: 3 | { 4 | host: 127.0.0.1 5 | port: 555 6 | } 7 | -------------------------------------------------------------------------------- /tests/assets/nu_json/stringify1_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | quotes: 3 | { 4 | num1: "1,2" 5 | num2: "-1.1 ," 6 | num3: "1e10 ,2" 7 | num4: "-1e-10," 8 | kw1: "true," 9 | kw2: "false ," 10 | kw3: "null,123" 11 | close1: "1}" 12 | close1b: "1 }" 13 | close2: "1]" 14 | close2b: "1 ]" 15 | close3: "1," 16 | close3b: "1 ," 17 | comment1: "1#str" 18 | comment2: "1//str" 19 | comment3: "1/*str*/" 20 | punc1: "{" 21 | punc1b: "{foo" 22 | punc2: "}" 23 | punc2b: "}foo" 24 | punc3: "[" 25 | punc3b: "[foo" 26 | punc4: "]" 27 | punc4b: "]foo" 28 | punc5: "," 29 | punc5b: ",foo" 30 | punc6: ":" 31 | punc6b: ":foo" 32 | } 33 | noquotes: 34 | { 35 | num0: .1,2 36 | num1: 1.1.1,2 37 | num2: -.1, 38 | num3: 1e10e,2 39 | num4: -1e--10, 40 | kw1: true1, 41 | kw2: false0, 42 | kw3: null0, 43 | close1: a} 44 | close2: a] 45 | comment1: a#str 46 | comment2: a//str 47 | comment3: a/*str*/ 48 | } 49 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/stringify1_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "quotes": { 3 | "num1": "1,2", 4 | "num2": "-1.1 ,", 5 | "num3": "1e10 ,2", 6 | "num4": "-1e-10,", 7 | "kw1": "true,", 8 | "kw2": "false ,", 9 | "kw3": "null,123", 10 | "close1": "1}", 11 | "close1b": "1 }", 12 | "close2": "1]", 13 | "close2b": "1 ]", 14 | "close3": "1,", 15 | "close3b": "1 ,", 16 | "comment1": "1#str", 17 | "comment2": "1//str", 18 | "comment3": "1/*str*/", 19 | "punc1": "{", 20 | "punc1b": "{foo", 21 | "punc2": "}", 22 | "punc2b": "}foo", 23 | "punc3": "[", 24 | "punc3b": "[foo", 25 | "punc4": "]", 26 | "punc4b": "]foo", 27 | "punc5": ",", 28 | "punc5b": ",foo", 29 | "punc6": ":", 30 | "punc6b": ":foo" 31 | }, 32 | "noquotes": { 33 | "num0": ".1,2", 34 | "num1": "1.1.1,2", 35 | "num2": "-.1,", 36 | "num3": "1e10e,2", 37 | "num4": "-1e--10,", 38 | "kw1": "true1,", 39 | "kw2": "false0,", 40 | "kw3": "null0,", 41 | "close1": "a}", 42 | "close2": "a]", 43 | "comment1": "a#str", 44 | "comment2": "a//str", 45 | "comment3": "a/*str*/" 46 | } 47 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/stringify1_test.hjson: -------------------------------------------------------------------------------- 1 | // test if stringify produces correct output 2 | { 3 | quotes: 4 | { 5 | num1: "1,2" 6 | num2: "-1.1 ," 7 | num3: "1e10 ,2" 8 | num4: "-1e-10," 9 | kw1: "true," 10 | kw2: "false ," 11 | kw3: "null,123" 12 | close1: "1}" 13 | close1b: "1 }" 14 | close2: "1]" 15 | close2b: "1 ]" 16 | close3: "1," 17 | close3b: "1 ," 18 | comment1: "1#str" 19 | comment2: "1//str" 20 | comment3: "1/*str*/" 21 | punc1: "{" 22 | punc1b: "{foo" 23 | punc2: "}" 24 | punc2b: "}foo" 25 | punc3: "[" 26 | punc3b: "[foo" 27 | punc4: "]" 28 | punc4b: "]foo" 29 | punc5: "," 30 | punc5b: ",foo" 31 | punc6: ":" 32 | punc6b: ":foo" 33 | } 34 | noquotes: 35 | { 36 | num0: ".1,2" 37 | num1: "1.1.1,2" 38 | num2: "-.1," 39 | num3: "1e10e,2" 40 | num4: "-1e--10," 41 | kw1: "true1," 42 | kw2: "false0," 43 | kw3: "null0," 44 | close1: "a}" 45 | close2: "a]" 46 | comment1: "a#str" 47 | comment2: "a//str" 48 | comment3: "a/*str*/" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/assets/nu_json/strings_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | text1: This is a valid string value. 3 | text2: a \ is just a \ 4 | text3: "You need quotes\tfor escapes" 5 | text4a: " untrimmed " 6 | text4b: " untrimmed" 7 | text4c: "untrimmed " 8 | multiline1: 9 | ''' 10 | first line 11 | indented line 12 | last line 13 | ''' 14 | multiline2: 15 | ''' 16 | first line 17 | indented line 18 | last line 19 | ''' 20 | multiline3: 21 | ''' 22 | first line 23 | indented line 24 | last line 25 | 26 | ''' 27 | foo1a: asdf\"'a\s\w 28 | foo1b: asdf\"'a\s\w 29 | foo1c: asdf\"'a\s\w 30 | foo2a: '''"asdf"''' 31 | foo2b: '''"asdf"''' 32 | foo3a: asdf''' 33 | foo3b: "'''asdf" 34 | foo4a: "asdf'''\nasdf" 35 | foo4b: "asdf\n'''asdf" 36 | arr: 37 | [ 38 | one 39 | two 40 | three 41 | four 42 | ] 43 | not: 44 | { 45 | number: 5 46 | negative: -4.2 47 | yes: true 48 | no: false 49 | null: null 50 | array: 51 | [ 52 | 1 53 | 2 54 | 3 55 | 4 56 | 5 57 | 6 58 | 7 59 | 8 60 | 9 61 | 0 62 | -1 63 | 0.5 64 | ] 65 | } 66 | special: 67 | { 68 | true: "true" 69 | false: "false" 70 | null: "null" 71 | one: "1" 72 | two: "2" 73 | minus: "-3" 74 | } 75 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/strings_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "text1": "This is a valid string value.", 3 | "text2": "a \\ is just a \\", 4 | "text3": "You need quotes\tfor escapes", 5 | "text4a": " untrimmed ", 6 | "text4b": " untrimmed", 7 | "text4c": "untrimmed ", 8 | "multiline1": "first line\n indented line\nlast line", 9 | "multiline2": "first line\n indented line\nlast line", 10 | "multiline3": "first line\n indented line\nlast line\n", 11 | "foo1a": "asdf\\\"'a\\s\\w", 12 | "foo1b": "asdf\\\"'a\\s\\w", 13 | "foo1c": "asdf\\\"'a\\s\\w", 14 | "foo2a": "\"asdf\"", 15 | "foo2b": "\"asdf\"", 16 | "foo3a": "asdf'''", 17 | "foo3b": "'''asdf", 18 | "foo4a": "asdf'''\nasdf", 19 | "foo4b": "asdf\n'''asdf", 20 | "arr": [ 21 | "one", 22 | "two", 23 | "three", 24 | "four" 25 | ], 26 | "not": { 27 | "number": 5, 28 | "negative": -4.2, 29 | "yes": true, 30 | "no": false, 31 | "null": null, 32 | "array": [ 33 | 1, 34 | 2, 35 | 3, 36 | 4, 37 | 5, 38 | 6, 39 | 7, 40 | 8, 41 | 9, 42 | 0, 43 | -1, 44 | 0.5 45 | ] 46 | }, 47 | "special": { 48 | "true": "true", 49 | "false": "false", 50 | "null": "null", 51 | "one": "1", 52 | "two": "2", 53 | "minus": "-3" 54 | } 55 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/strings_test.hjson: -------------------------------------------------------------------------------- 1 | { 2 | # simple 3 | 4 | text1: This is a valid string value. 5 | text2:a \ is just a \ 6 | 7 | text3: "You need quotes\tfor escapes" 8 | 9 | text4a: " untrimmed " 10 | text4b: " untrimmed" 11 | text4c: "untrimmed " 12 | 13 | # multiline string 14 | 15 | multiline1: 16 | ''' 17 | first line 18 | indented line 19 | last line 20 | ''' 21 | 22 | multiline2: 23 | '''first line 24 | indented line 25 | last line''' 26 | 27 | multiline3: 28 | ''' 29 | first line 30 | indented line 31 | last line 32 | 33 | ''' # trailing lf 34 | 35 | # escapes/no escape 36 | 37 | foo1a: asdf\"'a\s\w 38 | foo1b: '''asdf\"'a\s\w''' 39 | foo1c: "asdf\\\"'a\\s\\w" 40 | 41 | foo2a: "\"asdf\"" 42 | foo2b: '''"asdf"''' 43 | 44 | foo3a: "asdf'''" 45 | foo3b: "'''asdf" 46 | 47 | foo4a: "asdf'''\nasdf" 48 | foo4b: "asdf\n'''asdf" 49 | 50 | # in arrays 51 | arr: 52 | [ 53 | one 54 | two 55 | "three" 56 | '''four''' 57 | ] 58 | 59 | # not strings 60 | not: 61 | { 62 | number: 5 63 | negative: -4.2 64 | yes: true 65 | no: false 66 | null: null 67 | array: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1, 0.5 ] 68 | } 69 | 70 | # special quoted 71 | special: 72 | { 73 | true: "true" 74 | false: "false" 75 | null: "null" 76 | one: "1" 77 | two: "2" 78 | minus: "-3" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /tests/assets/nu_json/trail_result.hjson: -------------------------------------------------------------------------------- 1 | { 2 | foo: 0 -- this string starts at 0 and ends at 1, preceding and trailing whitespace is ignored -- 1 3 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/trail_result.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "0 -- this string starts at 0 and ends at 1, preceding and trailing whitespace is ignored -- 1" 3 | } -------------------------------------------------------------------------------- /tests/assets/nu_json/trail_test.hjson: -------------------------------------------------------------------------------- 1 | // the following line contains trailing whitespace: 2 | foo: 0 -- this string starts at 0 and ends at 1, preceding and trailing whitespace is ignored -- 1 3 | -------------------------------------------------------------------------------- /tests/fixtures/formats/appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | 3 | environment: 4 | global: 5 | PROJECT_NAME: nushell 6 | RUST_BACKTRACE: 1 7 | matrix: 8 | - TARGET: x86_64-pc-windows-msvc 9 | CHANNEL: nightly 10 | BITS: 64 11 | 12 | install: 13 | - set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% 14 | - curl -sSf -o rustup-init.exe https://win.rustup.rs 15 | # Install rust 16 | - rustup-init.exe -y --default-host %TARGET% --default-toolchain %CHANNEL%-%TARGET% 17 | - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin 18 | # Required for Racer autoconfiguration 19 | - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" 20 | 21 | 22 | build: false 23 | 24 | test_script: 25 | # compile #[cfg(not(test))] code 26 | - cargo build --verbose 27 | - cargo test --all --verbose 28 | 29 | cache: 30 | - target -> Cargo.lock 31 | - C:\Users\appveyor\.cargo\registry -> Cargo.lock 32 | -------------------------------------------------------------------------------- /tests/fixtures/formats/caco3_plastics.tsv: -------------------------------------------------------------------------------- 1 | importer shipper tariff_item name origin shipped_at arrived_at net_weight fob_price cif_price cif_per_net_weight 2 | PLASTICOS RIVAL CIA LTDA S A REVERTE 2509000000 CARBONATO DE CALCIO TIPO CALCIPORE 160 T AL SPAIN 18/03/2016 17/04/2016 81,000.00 14,417.58 18,252.34 0.23 3 | MEXICHEM ECUADOR S.A. OMYA ANDINA S A 2836500000 CARBONATO COLOMBIA 07/07/2016 10/07/2016 26,000.00 7,072.00 8,127.18 0.31 4 | PLASTIAZUAY SA SA REVERTE 2836500000 CARBONATO DE CALCIO SPAIN 27/07/2016 09/08/2016 81,000.00 8,100.00 11,474.55 0.14 5 | PLASTICOS RIVAL CIA LTDA AND ENDUSTRIYEL HAMMADDELER DIS TCARET LTD.STI. 2836500000 CALCIUM CARBONATE ANADOLU ANDCARB CT-1 TURKEY 04/10/2016 11/11/2016 100,000.00 17,500.00 22,533.75 0.23 6 | QUIMICA COMERCIAL QUIMICIAL CIA. LTDA. SA REVERTE 2836500000 CARBONATO DE CALCIO SPAIN 24/06/2016 12/07/2016 27,000.00 3,258.90 5,585.00 0.21 7 | PICA PLASTICOS INDUSTRIALES C.A. OMYA ANDINA S.A 3824909999 CARBONATO DE CALCIO COLOMBIA 01/01/1900 18/01/2016 66,500.00 12,635.00 18,670.52 0.28 8 | PLASTIQUIM S.A. OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYA CARB 1T CG BBS 1000 COLOMBIA 01/01/1900 25/10/2016 33,000.00 6,270.00 9,999.00 0.30 9 | QUIMICOS ANDINOS QUIMANDI S.A. SIBELCO COLOMBIA SAS 3824909999 CARBONATO DE CALCIO RECUBIERTO COLOMBIA 01/11/2016 03/11/2016 52,000.00 8,944.00 13,039.05 0.25 10 | TIGRE ECUADOR S.A. ECUATIGRE OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYACARB 1T CG BPA 25 NO COLOMBIA 01/01/1900 28/10/2016 66,000.00 11,748.00 18,216.00 0.28 11 | -------------------------------------------------------------------------------- /tests/fixtures/formats/jonathan.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Jonathan Turner 5 | http://www.jonathanturner.org 6 | 7 | 8 | 9 | Creating crossplatform Rust terminal apps 10 | <p><img src="/images/pikachu.jpg" alt="Pikachu animation in Windows" /></p> 11 | 12 | <p><em>Look Mom, Pikachu running in Windows CMD!</em></p> 13 | 14 | <p>Part of the adventure is not seeing the way ahead and going anyway.</p> 15 | 16 | Mon, 05 Oct 2015 00:00:00 +0000 17 | http://www.jonathanturner.org/2015/10/off-to-new-adventures.html 18 | http://www.jonathanturner.org/2015/10/off-to-new-adventures.html 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/fixtures/formats/random_numbers.csv: -------------------------------------------------------------------------------- 1 | random numbers 2 | 5 3 | 2 4 | 0 5 | 5 6 | 1 7 | 3 8 | 5 9 | 2 10 | 1 11 | 1 12 | 0 13 | 5 14 | 1 15 | 0 16 | 0 17 | 4 18 | 0 19 | 4 20 | 5 21 | 2 22 | 2 23 | 4 24 | 3 25 | 2 26 | 5 27 | 3 28 | 1 29 | 0 30 | 5 31 | 1 32 | 2 33 | 2 34 | 5 35 | 0 36 | 1 37 | 1 38 | 5 39 | 1 40 | 1 41 | 3 42 | 3 43 | 1 44 | 5 45 | 0 46 | 2 47 | 1 48 | 3 49 | 1 50 | 1 51 | 2 52 | -------------------------------------------------------------------------------- /tests/fixtures/formats/sample-ls-output.json: -------------------------------------------------------------------------------- 1 | [{"name":"a.txt","type":"File","size":3444,"modified":"2020-07-1918:26:30.560716967UTC"},{"name":"B.txt","type":"File","size":1341,"modified":"2020-07-1918:26:30.561021953UTC"},{"name":"C","type":"Dir","size":118253,"modified":"2020-07-1918:26:30.562092480UTC"}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/formats/sample-simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "first": "first", 3 | "second": "this\nshould\nbe\nseparate\nlines" 4 | } -------------------------------------------------------------------------------- /tests/fixtures/formats/sample.bson: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/sample.bson -------------------------------------------------------------------------------- /tests/fixtures/formats/sample.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/sample.db -------------------------------------------------------------------------------- /tests/fixtures/formats/sample.eml: -------------------------------------------------------------------------------- 1 | MIME-Version: 1.0 2 | Date: Fri, 28 Aug 2020 13:59:02 -0700 3 | Message-ID: 4 | Subject: Test Message 5 | From: "from@example.com" 6 | Reply-To: "replyto@example.com" 7 | To: to@example.com 8 | Content-Type: multipart/alternative; boundary="0000000000009d71fb05adf6528a" 9 | 10 | --0000000000009d71fb05adf6528a 11 | Content-Type: text/plain; charset="UTF-8" 12 | 13 | Test Message 14 | 15 | --0000000000009d71fb05adf6528a 16 | Content-Type: text/html; charset="UTF-8" 17 | 18 |
Test Message
19 | 20 | --0000000000009d71fb05adf6528a-- 21 | -------------------------------------------------------------------------------- /tests/fixtures/formats/sample.ini: -------------------------------------------------------------------------------- 1 | [SectionOne] 2 | 3 | key = value 4 | integer = 1234 5 | real = 3.14 6 | string1 = 'Case 1' 7 | string2 = "Case 2" 8 | 9 | [SectionTwo] 10 | 11 | ; comment line 12 | key = new value 13 | integer = 5678 14 | real = 3.14 15 | string1 = 'Case 1' 16 | string2 = "Case 2" 17 | string3 = 'Case 3' 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/fixtures/formats/sample.url: -------------------------------------------------------------------------------- 1 | bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter -------------------------------------------------------------------------------- /tests/fixtures/formats/sample_data.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/sample_data.ods -------------------------------------------------------------------------------- /tests/fixtures/formats/sample_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/sample_data.xlsx -------------------------------------------------------------------------------- /tests/fixtures/formats/sample_headers.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/sample_headers.xlsx -------------------------------------------------------------------------------- /tests/fixtures/formats/script.nu: -------------------------------------------------------------------------------- 1 | #!/Users/gedge/src/github.com/nushell/nushell/target/debug/nu 2 | echo "done" 3 | -------------------------------------------------------------------------------- /tests/fixtures/formats/script_multiline.nu: -------------------------------------------------------------------------------- 1 | echo [1 4] | length 2 | echo [2 3 5] | length 3 | -------------------------------------------------------------------------------- /tests/fixtures/formats/sgml_description.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Markup Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "Height": 10, 14 | "GlossDef": { 15 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 16 | "GlossSeeAlso": [ 17 | "GML", 18 | "XML" 19 | ] 20 | }, 21 | "Sections": [ 22 | 101, 23 | 102 24 | ], 25 | "GlossSee": "markup" 26 | } 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /tests/fixtures/formats/utf16.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nushell/engine-q/9259a56a28f1dd3a4b720ad815aa19c6eaf6adce/tests/fixtures/formats/utf16.ini -------------------------------------------------------------------------------- /tests/fixtures/playground/config/default.toml: -------------------------------------------------------------------------------- 1 | skip_welcome_message = true 2 | filesize_format = "auto" 3 | rm_always_trash = false 4 | -------------------------------------------------------------------------------- /tests/fixtures/playground/config/startup.toml: -------------------------------------------------------------------------------- 1 | skip_welcome_message = true 2 | 3 | startup = ["def hello-world [] { echo 'Nu World' }"] 4 | -------------------------------------------------------------------------------- /tests/main.rs: -------------------------------------------------------------------------------- 1 | extern crate nu_test_support; 2 | 3 | mod path; 4 | mod plugins; 5 | mod shell; 6 | -------------------------------------------------------------------------------- /tests/path/mod.rs: -------------------------------------------------------------------------------- 1 | mod canonicalize; 2 | mod expand_path; 3 | -------------------------------------------------------------------------------- /tests/plugins/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(features = "inc")] 2 | mod core_inc; 3 | -------------------------------------------------------------------------------- /tests/shell/environment/mod.rs: -------------------------------------------------------------------------------- 1 | mod env; 2 | mod nu_env; 3 | 4 | pub mod support { 5 | use nu_test_support::{nu, playground::*, Outcome}; 6 | 7 | pub struct Trusted; 8 | 9 | impl Trusted { 10 | pub fn in_path(dirs: &Dirs, block: impl FnOnce() -> Outcome) -> Outcome { 11 | let for_env_manifest = dirs.test().to_string_lossy(); 12 | 13 | nu!(cwd: dirs.root(), format!("autoenv trust \"{}\"", for_env_manifest)); 14 | let out = block(); 15 | nu!(cwd: dirs.root(), format!("autoenv untrust \"{}\"", for_env_manifest)); 16 | 17 | out 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/shell/pipeline/commands/mod.rs: -------------------------------------------------------------------------------- 1 | mod external; 2 | mod internal; 3 | -------------------------------------------------------------------------------- /tests/shell/pipeline/mod.rs: -------------------------------------------------------------------------------- 1 | mod commands; 2 | 3 | use nu_test_support::nu; 4 | 5 | #[test] 6 | fn doesnt_break_on_utf8() { 7 | let actual = nu!(cwd: ".", "echo ö"); 8 | 9 | assert_eq!(actual.out, "ö", "'{}' should contain ö", actual.out); 10 | } 11 | --------------------------------------------------------------------------------