Commit Graph

1042 Commits

Author SHA1 Message Date
Belhorma Bendebiche
8f9dd6516e Add =~ and !~ operators on strings
`left =~ right` return true if left contains right, using Rust's
`String::contains`. `!~` is the negated version.

A new `apply_operator` function is added which decouples evaluation from
`Value::compare`. This returns a `Value` and opens the door to
implementing `+` for example, though it wouldn't be useful immediately.

The `operator!` macro had to be changed slightly as it would choke on
`~` in arguments.
2019-12-02 11:02:57 -08:00
Yehuda Katz
e4226def16 Extract core stuff into own crates
This commit extracts five new crates:

- nu-source, which contains the core source-code handling logic in Nu,
  including Text, Span, and also the pretty.rs-based debug logic
- nu-parser, which is the parser and expander logic
- nu-protocol, which is the bulk of the types and basic conveniences
  used by plugins
- nu-errors, which contains ShellError, ParseError and error handling
  conveniences
- nu-textview, which is the textview plugin extracted into a crate

One of the major consequences of this refactor is that it's no longer
possible to `impl X for Spanned<Y>` outside of the `nu-source` crate, so
a lot of types became more concrete (Value became a concrete type
instead of Spanned<Value>, for example).

This also turned a number of inherent methods in the main nu crate into
plain functions (impl Value {} became a bunch of functions in the
`value` namespace in `crate::data::value`).
2019-12-02 10:54:12 -08:00
Jason Gedge
ac5543bad9 Move pipeline execution code into classified::Pipeline 2019-11-30 16:12:34 -05:00
Jonathan Turner
0a93335f6d Remove env var from starship 2019-11-30 08:38:44 +13:00
Jonathan Turner
b443a2d713
Merge pull request #1017 from jonathandturner/better_duration
improve duration print
2019-11-27 15:32:17 +13:00
Jonathan Turner
7a28ababd1
Update histogram.rs 2019-11-27 15:32:05 +13:00
Jonathan Turner
ddb9d3a864 improve duration print 2019-11-27 15:07:55 +13:00
Andrés N. Robalino
186b75a848
Merge pull request #1016 from andrasio/str
replace and find-replace str plugin additions.
2019-11-26 19:29:16 -05:00
Andrés N. Robalino
8cedd2ee5b replace and find-replace str plugin additions. 2019-11-26 19:03:22 -05:00
Jonathan Turner
9f42d7693f expand tilde in externals 2019-11-27 06:34:02 +13:00
Yehuda Katz
2eae5a2a89 Merge remote-tracking branch 'origin/master' into cleanup-wip 2019-11-25 19:25:12 -08:00
Andrés N. Robalino
70d63e34e9
Merge pull request #1008 from thegedge/move-pipeline-to-classified
Move pipeline code from cli to classified
2019-11-25 18:21:07 -05:00
Andrés N. Robalino
83ac65ced3
Merge pull request #997 from bndbsh/operator-contains
Add `=~` and `!~` operators on strings
2019-11-25 18:19:58 -05:00
Andrés N. Robalino
d320ffe742 nth can select more than one row at a time. 2019-11-25 17:16:58 -05:00
Belhorma Bendebiche
fbc6f01cfb Add =~ and !~ operators on strings
`left =~ right` return true if left contains right, using Rust's
`String::contains`. `!~` is the negated version.

A new `apply_operator` function is added which decouples evaluation from
`Value::compare`. This returns a `Value` and opens the door to
implementing `+` for example, though it wouldn't be useful immediately.

The `operator!` macro had to be changed slightly as it would choke on
`~` in arguments.
2019-11-25 15:06:11 -05:00
Yehuda Katz
3008434c0f Eliminate repetitive code and fix Unix failure 2019-11-25 11:09:59 -08:00
Yehuda Katz
5fbea31d15 Remove unused Display implementations
After the previous commit, nushell uses PrettyDebug and
PrettyDebugWithSource for our pretty-printed display output.

PrettyDebug produces a structured `pretty.rs` document rather than
writing directly into a fmt::Formatter, and types that implement
`PrettyDebug` have a convenience `display` method that produces a string
(to be used in situations where `Display` is needed for compatibility
with other traits, or where simple rendering is appropriate).
2019-11-25 10:07:20 -08:00
Yehuda Katz
f70c6d5d48 Extract nu_source into a crate
This commit extracts Tag, Span, Text, as well as source-related debug
facilities into a new crate called nu_source.

This change is much bigger than one might have expected because the
previous code relied heavily on implementing inherent methods on
`Tagged<T>` and `Spanned<T>`, which is no longer possible.

As a result, this change creates more concrete types instead of using
`Tagged<T>`. One notable example: Tagged<Value> became Value, and Value
became UntaggedValue.

This change clarifies the intent of the code in many places, but it does
make it a big change.
2019-11-25 07:37:33 -08:00
Jason Gedge
71e7eb7cfc Move all pipeline execution code from cli to classified::pipeline 2019-11-24 22:52:37 -05:00
Jason Gedge
339ec46961 Refactor classified.rs into separate modules.
Adds modules for internal, external, and dynamic commands, as well as
the pipeline functionality. These are exported as their old names from
the classified module so as to keep its "interface" the same.
2019-11-24 17:19:12 -05:00
Andrés N. Robalino
06857fbc52 Take all rows having the column present. 2019-11-24 04:35:36 -05:00
Andrés N. Robalino
1c830b5c95 default command introduced. 2019-11-24 04:20:08 -05:00
Andrés N. Robalino
a74145961e Always check the row's columns. 2019-11-24 01:25:41 -05:00
Andrés N. Robalino
91698b2657
Merge pull request #1003 from andrasio/compact
Compact.
2019-11-23 22:03:20 -05:00
Jonathan Turner
4d5f1f6023 Revert some of the recent styled string changes 2019-11-24 13:56:19 +13:00
Andrés N. Robalino
bc2d65cd2e Remove raw data debugging. 2019-11-23 19:16:25 -05:00
Andrés N. Robalino
1a0b339897 compact command introduced. 2019-11-23 19:05:44 -05:00
Andrés N. Robalino
8d3a937413 Display raw debugging data (rust represetantion). 2019-11-23 18:53:50 -05:00
Andrés N. Robalino
c8aa8cb842 debug command facelift. 2019-11-22 03:31:58 -05:00
Andrés N. Robalino
88c4473283 Remove fuzzysearch. 2019-11-22 03:25:09 -05:00
Yehuda Katz
cdb0eeafa2 --no-edit 2019-11-21 14:22:32 -08:00
David Mason
b3c021899c combine functions behind to/from-c/tsv commands
fixes #969, admittedly without a --delimiter alias

moves from_structured_data.rs to from_delimited_data.rs to better
identify its scope and adds to_delimited_data.rs. Now csv and tsv both
use the same code, tsv passes in a fixed '\t' argument where csv passes
in the value of --separator
2019-11-19 16:02:35 +00:00
Jonathan Turner
111fcf188e Add umask to unix --full list 2019-11-19 18:46:47 +13:00
Jonathan Turner
372f6c16b3 Fix build errors on latest nightly 2019-11-18 16:12:37 +13:00
Ludwig Stecher
a070cb8154 Format durations nicely 2019-11-17 22:51:56 +01:00
Jonathan Turner
95ca3ed4fa Remove fuzzy search because of compat issues 2019-11-18 08:01:17 +13:00
Jonathan Turner
c598cd4255 Fix tests 2019-11-18 06:38:44 +13:00
Jonathan Turner
2bb03d9813 Abbreviate ls by default, add --full flag 2019-11-18 06:10:50 +13:00
Jonathan Turner
6231367bc8 Make duration its own primitive 2019-11-17 18:48:48 +13:00
Jonathan Turner
a7d7098b1a
Merge pull request #977 from jonathandturner/from_xls
Add from-xlsx for importing excel files
2019-11-17 16:36:22 +13:00
Jonathan Turner
90aeb700ea Add from_xlsx for importing excel files 2019-11-17 16:18:41 +13:00
Jonathan Turner
f992f5de95
Update save.rs 2019-11-17 14:13:52 +13:00
Belhorma Bendebiche
946f7256e4 Improve error messages for save
`save` attempts to convert input based on the target filename extension,
and expects a stream of text otherwise. However the error message is
unclear and provides little guidance, hopefully this is less confusing
to new users.

It might be worthwhile to also add a hint about adding an extension,
though I'm not sure if it's possible to emit multiple diagnostics.
2019-11-16 19:08:38 -05:00
Jonathan Turner
dd36bf07f4 Process prompts once rather than twice 2019-11-17 09:42:35 +13:00
Jonathan Turner
2d4a225e2a Fix formatting 2019-11-17 09:06:00 +13:00
Jonathan Turner
db218e06dc Give rustyline non-ansi to begin with. Fixes Windows 2019-11-17 09:02:26 +13:00
Jonathan Turner
07db14f72e Merge master 2019-11-17 06:17:05 +13:00
Jonathan Turner
ce106bfda9 Fix build warnings 2019-11-16 21:23:04 +13:00
Jonathan Turner
3c3637b674 Add comparison between dates 2019-11-16 14:36:51 +13:00
uma0317
0756145caf Fix move file to diffrent partition on Windows 2019-11-15 11:52:51 +09:00
Thomas Hartmann
1060ba2206 Fixes --headerless functionality for from-ssv.
Squashed commit of the following:

commit fc59d47a2291461d84e0587fc0fe63af0dc26f9f
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Tue Nov 12 15:39:38 2019 +0100

    Fixes inconsistencies in output.

commit da4084e9fdd983557b101207b381e333a443e551
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Tue Nov 12 13:04:10 2019 +0100

    remove unused enum.

commit 7f6a105879c8746786b99fb19bb9f0860c41796a
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Tue Nov 12 12:58:41 2019 +0100

    Starts refactoring from_ssv.

commit b70ddd169ef0c900e03fb590cb171cc7181528db
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Tue Nov 12 11:34:06 2019 +0100

    Fixes --headerless for non-aligned columns.

commit 6332778dd26de8d07be77b291124115141479892
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Tue Nov 12 10:27:35 2019 +0100

    Fixes from-ssv headerless aligned-columns logic.

commit 747d8c812e06349b4a15b8c130721881d86fff98
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Mon Nov 11 23:53:59 2019 +0100

    fixes unit tests for ssv.

commit c77cb451623b37a7a9742c791a4fc38cad053d3d
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Mon Nov 11 22:49:21 2019 +0100

    it compiles! one broken test.

commit 08a05964f56cf92507c255057d0aaf2b6dbb6f45
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Mon Nov 11 18:52:54 2019 +0100

    Backed into a corner. Help.

commit c95ab683025a8007b8a6f8e1659f021a002df584
Author: Thomas Hartmann <thomas.o.hartmann@gmail.com>
Date:   Mon Nov 11 17:30:54 2019 +0100

    broken but on the way
2019-11-12 16:04:55 +01:00
Thomas Hartmann
0401087175 Refactors out structured parsing logic to a separate module. 2019-11-12 16:04:55 +01:00
Thomas Hartmann
f8dc06ef49 Changes implementation of --headerless for from-tsv. 2019-11-12 16:04:55 +01:00
Thomas Hartmann
282cb46ff1 Implements --headerless for from-csv 2019-11-12 16:04:55 +01:00
Andrés N. Robalino
00b3c2036a This is part of on-going work with capabilities when working with
tables and able to work with them for data processing & viewing
purposes. At the moment, certain ways to process said tables we
are able to view a histogram of a given column.

As usage matures, we may find certain core commands that could
be used ergonomically when working with tables on Nu.
2019-11-12 03:39:30 -05:00
Andrés N. Robalino
3163b0d362 Data processing mvp histogram. 2019-11-12 02:08:28 -05:00
Andrés N. Robalino
21f48577ae Reductions placeholder. 2019-11-12 02:08:28 -05:00
Jonathan Turner
0f405f24c7 Bump dep versions 2019-11-11 06:48:49 +13:00
Jonathan Turner
59ab11e932
Merge pull request #947 from jonathandturner/bump_and_plugin_load
Bump Nu version and change plugin load logic for debug
2019-11-09 21:29:09 -08:00
Jonathan Turner
df302d4bac Bump Nu version and change plugin load logic for debug 2019-11-10 16:44:05 +13:00
Jonathan Turner
62a5250554 Add format command 2019-11-10 13:14:59 +13:00
Jonathan Turner
9043970e97
Merge pull request #943 from drmason13/from_csv-add-separator-arg
Add --separator argument to from_csv
2019-11-09 15:09:32 -08:00
Jonathan Turner
bab58576b4 Rename read to parse 2019-11-10 11:26:44 +13:00
David Mason
4a6122905b fmt: cargo fmt --all 2019-11-08 15:27:29 +00:00
David Mason
15986c598a Add --separator command to from_csv
The command takes a string, checks it is a single character and then
passes it to csv::ReaderBuilder via .delimiter() method as a u8.
2019-11-08 15:06:33 +00:00
Jonathan Turner
44a1686a76 Move flags help to last 2019-11-06 15:28:26 +13:00
Jason Gedge
f012eb7bdd Eliminate is_first_command by defaulting to Value::nothing() 2019-11-03 20:06:59 -05:00
Andrés N. Robalino
f966394b63
Merge pull request #888 from andrasio/data-primitives
WIP [data processing]
2019-11-03 16:52:21 -05:00
Andrés N. Robalino
889d2bb378 Isolate feature. 2019-11-03 16:36:47 -05:00
Andrés N. Robalino
8860d8de8d At the moment, ColumnPaths represent a set of Members (eg. package.authors is a column path of two members)
The functions for retrieving, replacing, and inserting values into values all assumed they get the complete
column path as regular tagged strings. This commit changes for these to accept a tagged values instead. Basically
it means we can have column paths containing strings and numbers (eg. package.authors.1)

Unfortunately, for the moment all members when parsed and deserialized for a command that expects column paths
of tagged values will get tagged values (encapsulating Members) as strings only.

This makes it impossible to determine whether package.authors.1 package.authors."1" (meaning the "number" 1) is
a string member or a number member and thus prevents to know and force the user that paths enclosed in double
quotes means "retrieve the column at this given table" and that numbers are for retrieving a particular row number
from a table.

This commit sets in place the infraestructure needed when integer members land, in the mean time the workaround
is to convert back to strings the tagged values passed from the column paths.
2019-11-03 06:30:32 -05:00
Andrés N. Robalino
d7b768ee9f Fallback internally to String primitives until Member int serialization lands. 2019-11-03 05:38:47 -05:00
Andrés N. Robalino
6ea8e42331 Move column paths to support broader value types. 2019-11-03 05:38:47 -05:00
Andrés N. Robalino
1b784cb77a
Merge pull request #913 from andrasio/tests-builtins
`get` preserves anchored inputs.
2019-11-03 05:11:09 -05:00
Andrés N. Robalino
4a0ec1207c Preserve anchored meta data for all get queries in the pipeline 2019-11-03 03:49:06 -05:00
Jonathan Turner
3b42655b51 Make column logic in from-ssv optional 2019-11-03 17:04:59 +13:00
Jonathan Turner
c317094947 Add support for config --set_into 2019-11-03 12:43:15 +13:00
Jonathan Turner
243df63978 Move config to async_stream 2019-11-03 12:22:30 +13:00
Jonathan Turner
cd30fac050 Approach fix differently 2019-11-03 08:57:28 +13:00
Jonathan Turner
f589d3c795 Fix 907 and improve substring 2019-11-03 07:49:28 +13:00
Jonathan Turner
51879d022e
Merge pull request #895 from Flare576/substring
Adds new substring function to str plugin
2019-11-02 17:42:45 +13:00
Jonathan Turner
2260b3dda3
Update str.rs 2019-11-02 17:25:20 +13:00
Jonathan Turner
129ee45944 Add initial support for env vars 2019-11-02 16:41:58 +13:00
Jonathan Turner
e92d4b2ccb Rename add to insert 2019-11-02 14:47:14 +13:00
Jonathan Turner
7801c03e2d plugin_nu_path 2019-11-02 13:36:21 +13:00
Flare576
763bbe1c01 Updated Doc, error on bad input 2019-11-01 17:25:08 -05:00
Jonathan Turner
a3679f0f4e Make echo more flexible with data types 2019-11-02 08:15:53 +13:00
Jonathan Turner
e75fdc2865
Merge pull request #897 from nushell/modernize_external_tokens
Modernize external tokens
2019-11-02 06:18:38 +13:00
Yehuda Katz
4be88ff572 Modernize external parse and improve trace
The original purpose of this PR was to modernize the external parser to
use the new Shape system.

This commit does include some of that change, but a more important
aspect of this change is an improvement to the expansion trace.

Previous commit 6a7c00ea adding trace infrastructure to the syntax coloring
feature. This commit adds tracing to the expander.

The bulk of that work, in addition to the tree builder logic, was an
overhaul of the formatter traits to make them more general purpose, and
more structured.

Some highlights:

- `ToDebug` was split into two traits (`ToDebug` and `DebugFormat`)
  because implementations needed to become objects, but a convenience
  method on `ToDebug` didn't qualify
- `DebugFormat`'s `fmt_debug` method now takes a `DebugFormatter` rather
  than a standard formatter, and `DebugFormatter` has a new (but still
  limited) facility for structured formatting.
- Implementations of `ExpandSyntax` need to produce output that
  implements `DebugFormat`.

Unlike the highlighter changes, these changes are fairly focused in the
trace output, so these changes aren't behind a flag.
2019-11-01 08:45:45 -07:00
Flare576
cd058db046 Substring option for str plugin
Adds new substr function to str plugin with tests and documentation

Function takes a start/end location as a string in the form "##,##", both sides of comma are optional, and
behaves like Rust's own index operator [##..##].
2019-10-31 19:49:17 -05:00
Andrés N. Robalino
e31ed66610 get :: support fetching rows using numbers in column path. 2019-10-31 14:20:22 -05:00
Andrés N. Robalino
b54ce921dd Better error messages. 2019-10-31 04:36:08 -05:00
Andrés N. Robalino
7614ce4b49 Allow handling errors with failure callbacks. 2019-10-30 17:46:40 -05:00
Andrés N. Robalino
cea8fab307 "Integers" in column paths fetch a row from a table. 2019-10-30 05:55:26 -05:00
Jonathan Turner
a9cd6b4f7a Format files 2019-10-30 20:04:39 +13:00
Jonathan Turner
81691e07c6 Add prepend and append commands 2019-10-30 19:54:06 +13:00
Jonathan Turner
3820fef801 Add a simple read/parse plugin to better handle text data 2019-10-30 11:33:36 +13:00
Andrés N. Robalino
392ff286b2 This commit is ongoing work for making Nu working with data processing
a joy. Fundamentally we embrace functional programming principles for
transforming the dataset from any format picked up by Nu. This table
processing "primitive" commands will build up and make pipelines
composable with data processing capabilities allowing us the valuate,
reduce, and map, the tables as far as even composing this declartively.

On this regard, `split-by` expects some table with grouped data and we
can use it further in interesting ways (Eg. collecting labels for
visualizing the data in charts and/or suit it for a particular chart
of our interest).
2019-10-29 16:04:31 -05:00
Jonathan Turner
b6824d8b88
Merge pull request #886 from notryanb/fetch-from-variable
WIP fetch command - support reading url from variable
2019-10-29 13:52:35 +13:00
Ryan Blecher
e09160e80d add ability to create PathBuf from string to avoid type mismatch 2019-10-28 20:22:51 -04:00
Jonathan Turner
30b6eac03d Allow updating path in config 2019-10-29 10:22:31 +13:00
Jonathan Turner
53911ebecd Add support for :path 2019-10-29 07:40:34 +13:00
Jonathan Turner
bc309705a9
Merge pull request #883 from jonathandturner/magic_env_vars
Add support for $nu:config and $nu:env
2019-10-29 07:22:44 +13:00
Jonathan Turner
1de80aeac3 Add support for :config and :env 2019-10-29 06:51:08 +13:00
Andrés N. Robalino
1eaaf368ee
Merge pull request #879 from andrasio/tilde-pattern
Expand tilde in patterns.
2019-10-28 12:09:02 -05:00
Jonathan Turner
3f600c5b82 Fix build issues 2019-10-28 18:30:14 +13:00
Jonathan Turner
fbd980f8b0 Add descriptions to arguments 2019-10-28 18:15:35 +13:00
Jonathan Turner
aed386b3cd Always save history, add history command 2019-10-28 05:58:39 +13:00
Andrés N. Robalino
540cc4016e Expand tilde in patterns. 2019-10-27 03:55:30 -05:00
Andrés N. Robalino
2706ae076d Move out tags when parsing and building tree nodes. 2019-10-25 18:31:25 -05:00
Jonathan Turner
d160e834eb rustyline git and add plus for filenames 2019-10-26 05:43:31 +13:00
Jonathan Turner
571b33a11c
Merge pull request #857 from andrasio/group-by
Can group rows by given column name.
2019-10-23 18:25:52 +13:00
Andrés N. Robalino
f1630da2cc Suggest a column name in case one unknown column is supplied. 2019-10-22 20:10:42 -05:00
Andrés N. Robalino
16751b5dee color escaped external command. 2019-10-22 19:29:45 -05:00
Yehuda Katz
6a7c00eaef Finish the job of moving shapes into the stream
This commit should finish the `coloring_in_tokens` feature, which moves
the shape accumulator into the token stream. This allows rollbacks of
the token stream to also roll back any shapes that were added.

This commit also adds a much nicer syntax highlighter trace, which shows
all of the paths the highlighter took to arrive at a particular coloring
output. This change is fairly substantial, but really improves the
understandability of the flow. I intend to update the normal parser with
a similar tracing view.

In general, this change also fleshes out the concept of "atomic" token
stream operations.

A good next step would be to try to make the parser more
error-correcting, using the coloring infrastructure. A follow-up step
would involve merging the parser and highlighter shapes themselves.
2019-10-22 16:19:22 -07:00
Antti Keränen
8f035616a0 Fix enter crashing on nonexistent file
Fixes #839
2019-10-22 15:22:47 +03:00
Andrés N. Robalino
4329629ee9 baseline coverage for xml parsing. 2019-10-22 03:47:59 -05:00
Andrés N. Robalino
0611f56776 Can group cells by given column name. 2019-10-20 18:42:07 -05:00
Jonathan Turner
8923e91e39
Merge pull request #856 from andrasio/value-improvements
Improvements to Value mutable operations.
2019-10-21 06:57:36 +13:00
Jonathan Turner
d6e6811bb9
Merge pull request #854 from jdvr/master
#194 Connect `rm` command to platform's recycle bin
2019-10-21 05:16:48 +13:00
Andrés N. Robalino
f24bc5c826 Improvements to Value mutable operations. 2019-10-20 06:55:56 -05:00
jdvr
c209d0d487 194 Fixed file format 2019-10-19 22:52:39 +02:00
jdvr
74dddc880d "#194 Added trash switch checked before normal rm command action" 2019-10-19 22:31:18 +02:00
Jonathan Turner
f3c41bbdf1
Merge pull request #851 from t-hart/pr/remove-unwrap-unit
Deletes impl From<&str> for Unit
2019-10-20 07:29:07 +13:00
Jonathan Turner
c45ddc8f22
Merge pull request #848 from andrasio/column_path-inc
Inc plugin increments appropiately given a table containing a version.
2019-10-20 07:27:47 +13:00
Jonathan Turner
84a98995bf
Merge pull request #845 from t-hart/from-ssv/headers-as-markers
`from-ssv` logic updated
2019-10-20 07:26:04 +13:00
notryanb@gmail.com
43fbf4345d remove comment and add test for averaging integers 2019-10-18 20:43:37 -04:00
notryanb@gmail.com
8262c2dd33 add support for average on byte columns and fmt the code 2019-10-18 20:43:37 -04:00
notryanb@gmail.com
0e86430ea3 get very basic average working 2019-10-18 20:43:37 -04:00
jdvr
fc1301c92d #194 Added trash crate and send files to the trash using a flag 2019-10-19 00:41:24 +02:00
Thomas Hartmann
e913e26c01 Deletes impl From<&str>
The code still compiles, so this doesn't seem to break anything. That also means
it's not critical to fix it, but having dead code around isn't great either.
2019-10-18 20:02:24 +02:00
Andrés N. Robalino
5ce4b12cc1 Inc plugin increments appropiately given a table containing a version in it. 2019-10-18 07:30:36 -05:00
Antti Keränen
321629a693 Fix size comparison in 'where size'
Fixes #840
2019-10-17 22:57:02 +03:00
Thomas Hartmann
f21405399c Formats file. 2019-10-17 09:56:06 +02:00
Thomas Hartmann
305ca11eb5 Changes the parsing to use the full value of the final column.
Previously it would split the last column on the first separator value found
between the start of the column and the end of the row. Changing this to using
everything from the start of the column to the end of the string makes it behave
more similarly to the other columns, making it less surprising.
2019-10-17 09:40:00 +02:00
Thomas Hartmann
9b1ff9b566 Updates the table creation logic.
The table parsing/creation logic has changed from treating every line the same
to processing each line in context of the column header's placement. Previously,
lines on separate rows would go towards the same column as long as they were the
same index based on separator alone. Now, each item's index is based on vertical
alignment to the column header.

This may seem brittle, but it solves the problem of some tables operating with
empty cells that would cause remaining values to be paired with the wrong
column.

Based on kubernetes output (get pods, events), the new method has shown to have
much greater success rates for parsing.
2019-10-17 00:25:43 +02:00
Thomas Hartmann
a0ed6ea3c8 Adds new tests and updates old ones.
New tests are added to test for additional cases that might be trickier to
handle with the new logic.

Old tests are updated where their expectations are no longer expected to hold true.
For instance: previously, lines would be treated separately, allowing any index
offset between columns on different rows, as long as they had the same row index
as decided by a separator. When this is no longer the case, some things need to
be adjusted.
2019-10-17 00:17:58 +02:00
Jonathan Turner
9a02fac0e5
Rename <unknown> to <value> 2019-10-17 07:28:49 +13:00
Thomas Hartmann
74b0e4e541 Adds more info to the usage string. 2019-10-15 23:20:06 +02:00
Thomas Hartmann
f8d44e732b Updates default minimum spaces to allow single spaces by default. 2019-10-15 22:05:47 +02:00
Thomas Hartmann
0d2044e72e Changes flag to minimum-spaces. 2019-10-15 22:05:32 +02:00
Thomas Hartmann
294c2c600d Update the usage string to match the readme. 2019-10-15 21:10:15 +02:00
Thomas Hartmann
d32e97b812 Implements variable space separator length, version 1. 2019-10-15 20:48:06 +02:00
Thomas Hartmann
81affaa584 Adds tests for allowed-spaces option. 2019-10-15 19:10:38 +02:00
Andrés N. Robalino
0373006710 Formatting. 2019-10-15 05:42:24 -05:00
Andrés N. Robalino
ec2e35ad81 'last' gets last row if no amount desired given. 2019-10-15 05:41:34 -05:00
Andrés N. Robalino
821ee5e726 count command introduced. 2019-10-15 05:19:06 -05:00
Andrés N. Robalino
96ef478fbc Better error messages. 2019-10-15 04:18:35 -05:00
Andrés N. Robalino
3f60c9d416 'first' gets first row if no amount desired given. 2019-10-15 04:17:55 -05:00
Jonathan Turner
bd6d8189f8
Merge pull request #830 from t-hart/pull-req/from-master
[DRAFT] Adds `from-ssv` command.
2019-10-15 18:28:43 +13:00
Yehuda Katz
d1ebc55ed7
Merge pull request #831 from nushell/coloring_in_tokens
Start moving coloring into the token stream
2019-10-14 18:31:21 -07:00
Yehuda Katz
f20f3f56c7 Start moving coloring into the token stream
The benefit of this is that coloring can be made atomic alongside token
stream forwarding.

I put the feature behind a flag so I can continue to iterate on it
without possibly regressing existing functionality. It's a lot of places
where the flags have to go, but I expect it to be a short-lived flag,
and the flags are fully contained in the parser.
2019-10-14 16:11:00 -07:00
Thomas Hartmann
d21389d549 Removes unwrap.
A rogue unwrap had been left in the code, but has now been replaced by an option.
2019-10-15 00:24:32 +02:00
Thomas Hartmann
b2c53a0967 Updates commands to work after tag is no longer copy. 2019-10-14 23:14:45 +02:00
Thomas Hartmann
65546646a7 Pull in upstream changes. 2019-10-14 23:05:52 +02:00
Jason Gedge
ee8cd671cb Fix bug with multiple input objects to an external command.
Previously, we would build a command that looked something like this:

  <ex_cmd> "$it" "&&" "<ex_cmd>" "$it"

So that the "&&" and "<ex_cmd>" would also be arguments to the command,
instead of a chained command. This commit builds up a command string
that can be passed to an external shell.
2019-10-14 16:47:12 -04:00
Thomas Hartmann
22d2360c4b Adds conversion test for leading whitespace.
Refactors string parsing into a separate function.
2019-10-14 22:00:25 +02:00
Jonathan Turner
d38b8cf851
Merge pull request #827 from andrasio/external-color
Color escaped externals.
2019-10-15 08:28:34 +13:00
Andrés N. Robalino
43cf52275b Color escaped externals. 2019-10-14 14:09:44 -05:00
Thomas Hartmann
104b7824f5 Updates return types. 2019-10-14 16:34:06 +02:00
Thomas Hartmann
a9293f62a8 Adds some initial ideas for refactoring. 2019-10-14 09:43:54 +02:00
Thomas Hartmann
0b210ce5bf Filters out empty lines before table creation. 2019-10-14 07:48:19 +02:00
Thomas Hartmann
38225d0dba Removes extra newline 2019-10-14 07:48:10 +02:00
Thomas Hartmann
63039666b0 Changes from_ssv_to_string_value to return an Option. 2019-10-14 07:37:34 +02:00
Jonathan Turner
a4a1588fbc Fix confusing unnamed column and crash 2019-10-14 18:28:54 +13:00
Jonathan Turner
4eafb22d5b
Merge pull request #821 from jonathandturner/fix_809
Don't panick of no suggestions are found
2019-10-14 18:17:16 +13:00
Jonathan Turner
7c40aed738 Don't panick of no suggestions are found 2019-10-14 18:00:10 +13:00
Jonathan Turner
6c0bf6e0ab Fix panic if external is not found 2019-10-14 17:48:27 +13:00
Thomas Hartmann
20e891db6e Move variable assignment to clarify use. 2019-10-13 23:10:54 +02:00
Thomas Hartmann
38b5979881 Make usage string clearer. 2019-10-13 23:09:24 +02:00
Thomas Hartmann
de1c4e6c88 Implements from-ssv 2019-10-13 22:50:45 +02:00
Thomas Hartmann
648d4865b1 Adds unimplemented module, tests. 2019-10-13 21:15:30 +02:00
Jason Gedge
341cc1ea63 Ignore errors in ls.
`std::fs::metadata` will attempt to follow symlinks, which results in a
"No such file or directory" error if the path pointed to by the symlink
does not exist. This shouldn't prevent `ls` from succeeding, so we
ignore errors.

Also, switching to use of `symlink_metadata` means we get stat info on
the symlink itself, not what it points to. This means `ls` will now
include broken symlinks in its listing.
2019-10-13 12:26:31 -04:00
Jonathan Turner
2716bb020f
Fix #811 (#813) 2019-10-13 17:53:58 +13:00
Jonathan Turner
193b00764b
Stream support (#812)
* Moves off of draining between filters. Instead, the sink will pull on the stream, and will drain element-wise. This moves the whole stream to being lazy.
* Adds ctrl-c support and connects it into some of the key points where we pull on the stream. If a ctrl-c is detect, we immediately halt pulling on the stream and return to the prompt.
* Moves away from having a SourceMap where anchor locations are stored. Now AnchorLocation is kept directly in the Tag.
* To make this possible, split tag and span. Span is largely used in the parser and is copyable. Tag is now no longer copyable.
2019-10-13 17:12:43 +13:00
Yehuda Katz
439889dcef Feature flagging infrastructure
This commit adds the ability to work on features behind a feature flag
that won't be included in normal builds of nu.

These features are not exposed as Cargo features, as they reflect
incomplete features that are not yet stable.

To create a feature, add it to `features.toml`:

```toml
[hintsv1]

description = "Adding hints based on error states in the highlighter"
enabled = false
```

Each feature in `features.toml` becomes a feature flag accessible to `cfg`:

```rs
println!("hintsv1 is enabled");
```

By default, features are enabled based on the value of the `enabled` field.

You can also enable a feature from the command line via the
`NUSHELL_ENABLE_FLAGS` environment variable:

```sh
$ NUSHELL_ENABLE_FLAGS=hintsv1 cargo run
```

You can enable all flags via `NUSHELL_ENABLE_ALL_FLAGS`.

This commit also updates the CI setup to run the build with all flags off and
with all flags on. It also extracts the linting test into its own
parallelizable test, which means it doesn't need to run together with every
other test anymore.

When working on a feature, you should also add tests behind the same flag. A
commit is mergable if all tests pass with and without the flag, allowing
incomplete commits to land on master as long as the incomplete code builds and
passes tests.
2019-10-11 17:19:44 -07:00
Yehuda Katz
c2c10e2bc0 Overhaul the coloring system
This commit replaces the previous naive coloring system with a coloring
system that is more aligned with the parser.

The main benefit of this change is that it allows us to use parsing
rules to decide how to color tokens.

For example, consider the following syntax:

```
$ ps | where cpu > 10
```

Ideally, we could color `cpu` like a column name and not a string,
because `cpu > 10` is a shorthand block syntax that expands to
`{ $it.cpu > 10 }`.

The way that we know that it's a shorthand block is that the `where`
command declares that its first parameter is a `SyntaxShape::Block`,
which allows the shorthand block form.

In order to accomplish this, we need to color the tokens in a way that
corresponds to their expanded semantics, which means that high-fidelity
coloring requires expansion.

This commit adds a `ColorSyntax` trait that corresponds to the
`ExpandExpression` trait. The semantics are fairly similar, with a few
differences.

First `ExpandExpression` consumes N tokens and returns a single
`hir::Expression`. `ColorSyntax` consumes N tokens and writes M
`FlatShape` tokens to the output.

Concretely, for syntax like `[1 2 3]`

- `ExpandExpression` takes a single token node and produces a single
  `hir::Expression`
- `ColorSyntax` takes the same token node and emits 7 `FlatShape`s
  (open delimiter, int, whitespace, int, whitespace, int, close
  delimiter)

Second, `ColorSyntax` is more willing to plow through failures than
`ExpandExpression`.

In particular, consider syntax like

```
$ ps | where cpu >
```

In this case

- `ExpandExpression` will see that the `where` command is expecting a
  block, see that it's not a literal block and try to parse it as a
  shorthand block. It will successfully find a member followed by an
  infix operator, but not a following expression. That means that the
  entire pipeline part fails to parse and is a syntax error.
- `ColorSyntax` will also try to parse it as a shorthand block and
  ultimately fail, but it will fall back to "backoff coloring mode",
  which parsing any unidentified tokens in an unfallible, simple way. In
  this case, `cpu` will color as a string and `>` will color as an
  operator.

Finally, it's very important that coloring a pipeline infallibly colors
the entire string, doesn't fail, and doesn't get stuck in an infinite
loop.

In order to accomplish this, this PR separates `ColorSyntax`, which is
infallible from `FallibleColorSyntax`, which might fail. This allows the
type system to let us know if our coloring rules bottom out at at an
infallible rule.

It's not perfect: it's still possible for the coloring process to get
stuck or consume tokens non-atomically. I intend to reduce the
opportunity for those problems in a future commit. In the meantime, the
current system catches a number of mistakes (like trying to use a
fallible coloring rule in a loop without thinking about the possibility
that it will never terminate).
2019-10-10 19:30:04 -07:00
Yehuda Katz
1ad9d6f199 Overhaul the expansion system
The main thrust of this (very large) commit is an overhaul of the
expansion system.

The parsing pipeline is:

- Lightly parse the source file for atoms, basic delimiters and pipeline
  structure into a token tree
- Expand the token tree into a HIR (high-level intermediate
  representation) based upon the baseline syntax rules for expressions
  and the syntactic shape of commands.

Somewhat non-traditionally, nu doesn't have an AST at all. It goes
directly from the token tree, which doesn't represent many important
distinctions (like the difference between `hello` and `5KB`) directly
into a high-level representation that doesn't have a direct
correspondence to the source code.

At a high level, nu commands work like macros, in the sense that the
syntactic shape of the invocation of a command depends on the
definition of a command.

However, commands do not have the ability to perform unrestricted
expansions of the token tree. Instead, they describe their arguments in
terms of syntactic shapes, and the expander expands the token tree into
HIR based upon that definition.

For example, the `where` command says that it takes a block as its first
required argument, and the description of the block syntactic shape
expands the syntax `cpu > 10` into HIR that represents
`{ $it.cpu > 10 }`.

This commit overhauls that system so that the syntactic shapes are
described in terms of a few new traits (`ExpandSyntax` and
`ExpandExpression` are the primary ones) that are more composable than
the previous system.

The first big win of this new system is the addition of the `ColumnPath`
shape, which looks like `cpu."max ghz"` or `package.version`.
Previously, while a variable path could look like `$it.cpu."max ghz"`,
the tail of a variable path could not be easily reused in other
contexts. Now, that tail is its own syntactic shape, and it can be used
as part of a command's signature.

This cleans up commands like `inc`, `add` and `edit` as well as
shorthand blocks, which can now look like `| where cpu."max ghz" > 10`
2019-10-10 08:27:51 -07:00
Barnaby Keene
f8d337ad29 chore: omit the entire git.rs file when starship is used 2019-10-09 08:42:46 +01:00
Barnaby Keene
c8671c719f fix: addressed unused imports and dead code 2019-10-08 21:50:28 +01:00
Barnaby Keene
0412c3a2f8 fix: remove the additional characters from highlighter
This resolves a small integration issue that would make custom prompts problematic (if they are implemented). The approach was to use the highlighter implementation in Helper to insert colour codes to the prompt however it heavily relies on the prompt being in a specific format, ending with a `> ` sequence. However, this should really be the job of the prompt itself not the presentation layer.

For now, I've simply stripped off the additional `> ` characters and passed in just the prompt itself without slicing off the last two characters. I moved the `\x1b[m` control sequence to the prompt creation in `cli.rs` as this feels like the more logical home for controlling what the prompt looks like. I can think of better ways to do this in future but this should be a fine solution for now.

In future it would probably make sense to completely separate prompts (be it, internal or external) from this code so it can be configured as an isolated piece of code.
2019-10-08 21:39:58 +01:00
Barnaby Keene
fb8cfeb70d feat: starship prompt
Kind of touches on #356 by integrating the Starship prompt directly into the shell.

Not finished yet and has surfaced a potential bug in rustyline anyway. It depends on https://github.com/starship/starship/pull/509 being merged so the Starship prompt can be used as a library.

I could have tackled #356 completely and implemented a full custom prompt feature but I felt this was a simpler approach given that Starship is both written in Rust so shelling out isn't necessary and it already has a bunch of useful features built in.

However, I would understand if it would be preferable to just scrap integrating Starship directly and instead implement a custom prompt system which would facilitate simply shelling out to Starship.
2019-10-08 16:25:12 +01:00
Andrés N. Robalino
7492131142
Merge pull request #770 from rnxpyke/master
add regex match plugin
2019-10-03 14:20:41 -05:00
rnxypke
9181a046ec use correct argument for error message 2019-10-03 08:21:24 +02:00
Jonathan Rothberg
e54cd98a9c Put code into None case of last match. 2019-10-02 20:41:53 -07:00
Jonathan Rothberg
f3eb4fb24e Attempt at fixing get command panic.
If possible matches are not found then check if the passed in `obj`
parameter is a `string` or a `path`, if so then return it.  I am not
sure this is the right fix, but I figured I would make an attempt and
get a conversation started about it.
2019-10-02 20:16:27 -07:00
Jonathan Rothberg
7d2747ea9a Added Vi support for scrolling in the textview command. 2019-10-02 18:45:23 -07:00
rnxypke
36f2b09cad run rustfmt on match plugin 2019-10-02 22:41:52 +02:00
rnxypke
be51aad9ad remove unused imports on match plugin 2019-10-02 22:24:37 +02:00
rnxypke
9fb9adb6b4 add regex match plugin 2019-10-02 20:56:43 +02:00
Jonathan Rothberg
093b9c1c5b Fixed last command crash
When the last command has an input value larger than the data its
operating on it would crash.  Added a check to ensure there are enough
elements to take.
2019-09-29 20:20:18 -07:00
Jonathan Turner
348d75112f
Merge pull request #736 from pizzafox/fix/https-links
Use HTTPS where possible
2019-09-30 14:43:15 +13:00
Jonathan Turner
3c7b1ba854
Merge pull request #735 from rnxpyke/master
remove trailing newline after external command
2019-09-30 12:16:36 +13:00
rnxypke
3812037e2a remove trailing newline after external command 2019-09-30 00:43:23 +02:00
Jonathan Rothberg
83d82a09b2 Better handling of unexpected error case. 2019-09-29 14:43:39 -07:00
Jonah Snider
9c23d78513 docs: use HTTPS where possible
Signed-off-by: Jonah Snider <me@jonahsnider.ninja>
2019-09-29 09:03:51 -10:00
Jonathan Rothberg
ff92123d93 Merge remote-tracking branch 'upstream/master' into post-headers 2019-09-29 01:33:21 -07:00
Jonathan Rothberg
e1357a9541 Handle unexpected input and some cleanup. 2019-09-29 01:29:43 -07:00
Jonathan Turner
ce947d70b0 Rename SpanSource to AnchorLocation 2019-09-29 18:18:59 +13:00
Jonathan Turner
caed87c125 Rename origin to anchor 2019-09-29 18:13:56 +13:00
Jonathan Rothberg
e12ba5be8f Added support for more post headers. 2019-09-28 19:03:10 -07:00
Jonathan Rothberg
542a3995ea Merge remote-tracking branch 'upstream/master' into initial-docker-command-impl 2019-09-27 20:22:30 -07:00
Jonathan Rothberg
4af0dbe441 Removed commented code and added feature to Cargo.toml 2019-09-27 20:21:30 -07:00
est31
7a124518c3 Remove use of nightly features 2019-09-28 02:07:09 +02:00
est31
1183d28b15 Remove uses of async_stream_block 2019-09-28 02:05:18 +02:00
est31
6aad0b8443 Remove async_stream_block from the prelude
... to indicate deprecation of its use
2019-09-26 02:39:59 +02:00
est31
9891e5ab81 Use async-stream crate to replace most async_stream_block invocations 2019-09-26 02:39:20 +02:00
Jonathan Turner
7113c702ff
Merge pull request #706 from landaire/ctrlc_config
feat(cli): add `ctrlc_exit` config option
2019-09-26 09:22:11 +12:00
Jonathan Rothberg
2941740df6 Merge remote-tracking branch 'upstream/master' into initial-docker-command-impl 2019-09-24 20:43:03 -07:00
Jonathan Rothberg
f0b638063d Transfered Docker to a plugin instead of a Command. 2019-09-24 20:42:18 -07:00
Lander Brandt
0377efdc16 feat(cli): add ctrlc_exit config option
This feature allows a user to set `ctrlc_exit` to `true` or `false` in their config to override how multiple CTRL-C invocations are handled. Without this change pressing CTRL-C multiple times will exit nu. With this change applied the user can configure the behavior to behave like other shells where multiple invocations will essentially clear the line.

This fixes #457.
2019-09-24 18:04:53 -07:00
Jonathan Turner
3d89d2961c
Merge pull request #705 from piotrek-szczygiel/master
Fix typo in echo usage message
2019-09-25 12:46:35 +12:00
Piotr Szczygieł
85cd03f899 Fix typo in echo usage message 2019-09-25 00:15:53 +02:00
Pirmin Kalberer
3480cdb3b4 Fix build without crossterm 2019-09-24 23:33:30 +02:00
Andrés N. Robalino
837d12decd Filesystem shell can't cd into files. Ever. 2019-09-24 15:34:30 -05:00
Jonathan Turner
15481b7be1 Fix nth regression 2019-09-24 19:56:03 +12:00
Jonathan Turner
60b7da8ea7 Fix help regression 2019-09-24 19:45:41 +12:00
Jonathan Rothberg
a1f26d947d Merge remote-tracking branch 'upstream/master' into initial-docker-command-impl 2019-09-23 17:57:56 -07:00
Andrés N. Robalino
898b99d7c2 Ignore incompatible plugins and continue plugin search. 2019-09-23 17:27:18 -05:00
Andrés N. Robalino
95ea3fcf4e Load plugin if and only if it hasn't been registered. 2019-09-23 17:01:40 -05:00
Jonathan Turner
c720cc00e3 More 'did you mean?' errors 2019-09-24 08:24:51 +12:00
Jonathan Rothberg
e6bdef696d Some cleanup. 2019-09-22 20:19:43 -07:00
Jonathan Rothberg
707af3f3ca Merge branch 'master' of github.com:jonnywalker81/nushell into initial-docker-command-impl 2019-09-22 18:53:31 -07:00
Jonathan Rothberg
480467447e Initial Docker command implementation. 2019-09-22 18:49:11 -07:00
Pirmin Kalberer
9623a255c4 Include history path in env command 2019-09-20 10:37:05 +02:00
Pirmin Kalberer
112e5d096f Include config path in env command 2019-09-19 23:07:09 +02:00
Pirmin Kalberer
484d8c26ac Save history when leaving with Ctrl-C 2019-09-19 22:55:53 +02:00
Pirmin Kalberer
df7a3a4863 Store history.txt in user data path 2019-09-19 22:29:11 +02:00
Pirmin Kalberer
d7e7f48aaa Deactivate fuzzy search on Windows for now 2019-09-19 20:45:58 +02:00
Pirmin Kalberer
639a316677 Fix selection list display glitches 2019-09-19 20:18:39 +02:00
Pirmin Kalberer
0c9a62aeec Separate highlighting from fuzzy search 2019-09-19 20:18:39 +02:00
Pirmin Kalberer
0a0be19bed Rename histsearch to fuzzysearch 2019-09-19 20:18:39 +02:00
Pirmin Kalberer
1c95bf05dc Process selected command 2019-09-19 20:18:39 +02:00
Pirmin Kalberer
1e3549571c Bind fuzzy history search to Ctrl-R 2019-09-19 20:18:39 +02:00
Pirmin Kalberer
44b7e07569 Add Sublime style history search demo 2019-09-19 20:15:48 +02:00
Jonathan Turner
5ff94004c6 Add urlencode/urldecode 2019-09-19 16:25:29 +12:00
Jonathan Turner
3659e51163 Fix origin in binaryview 2019-09-18 19:18:58 +12:00
Jonathan Turner
72e6222992 Switch to using Uuid::nil() and fix test 2019-09-18 19:05:33 +12:00
Jonathan Turner
2cf7249794 Fix autoview breakage 2019-09-18 18:37:04 +12:00
Jonathan Turner
f6b82e4c0c Replace vtable with pivot command 2019-09-17 19:07:11 +12:00
Jonathan Turner
7fbd6ce232 Fix internal paths 2019-09-17 14:09:15 +12:00
Jonathan Turner
17855d37a4 Add env command 2019-09-16 19:52:58 +12:00
Jonathan Turner
88c1b1dc6f Improve default features and don't precompute ls 2019-09-15 13:51:19 +12:00
Andrés N. Robalino
6bb277baaa
Merge pull request #668 from nushell/span-to-tag
Span to tag
2019-09-14 15:10:04 -05:00
Andrés N. Robalino
dc4421c07d
Str flags no longer supported. 2019-09-14 14:50:26 -05:00
Jonathan Turner
2b88f1eed0 Serialize bigint/bigdecimal as i64/f64 2019-09-15 05:48:24 +12:00
Yehuda Katz
17d2a27350 Fixed lints 2019-09-14 12:16:52 -05:00
Yehuda Katz
19767ad551 Taking another stab at replacing Span with Tag 2019-09-14 11:48:45 -05:00
Yehuda Katz
ab915f1c44 Revert "Revert "Migrate most uses of the Span concept to Tag""
This reverts commit bee7c5639c.
2019-09-14 11:30:24 -05:00
Jonathan Turner
9382a7e64a Detach externals so they don't freeze while buffering 2019-09-14 05:51:40 +12:00
Jonathan Turner
53cb40d8f6 Add basic 'did you mean' support 2019-09-13 15:44:21 +12:00