Commit Graph

42 Commits

Author SHA1 Message Date
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
Yehuda Katz
cdb0eeafa2 --no-edit 2019-11-21 14:22:32 -08:00
Jonathan Turner
ce106bfda9 Fix build warnings 2019-11-16 21:23:04 +13:00
Jonathan Turner
fbd980f8b0 Add descriptions to arguments 2019-10-28 18:15:35 +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
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 Turner
3659e51163 Fix origin in binaryview 2019-09-18 19:18:58 +12:00
Jonathan Turner
189877e4dd Improve help and make binary a primitive 2019-09-13 06:29:16 +12:00
Andrés N. Robalino
ba8383ae2f to-[csv/tsv] fixes. 2019-09-10 07:00:25 -05:00
Yehuda Katz
7fa09f59c2 Remove unused code
Closes #467
2019-09-01 23:11:05 -07:00
Andrés N. Robalino
ca0c6eaf58 This commit introduces a basic help feature. We can go to it
with the `help` command to explore and list all commands available.

Enter will also try to see if the location to be entered is an existing
Nu command, if it is it will let you inspect the command under `help`.

This provides baseline needed so we can iterate on it.
2019-08-31 19:06:11 -05:00
Jonathan Turner
3750a04cfc
Merge branch 'master' into expand-tilde 2019-08-27 16:23:56 +12:00
Yehuda Katz
34292b282a Add support for ~ expansion
This ended up being a bit of a yak shave. The basic idea in this commit is to
expand `~` in paths, but only in paths.

The way this is accomplished is by doing the expansion inside of the code that
parses literal syntax for `SyntaxType::Path`.

As a quick refresher: every command is entitled to expand its arguments in a
custom way. While this could in theory be used for general-purpose macros,
today the expansion facility is limited to syntactic hints.

For example, the syntax `where cpu > 0` expands under the hood to
`where { $it.cpu > 0 }`. This happens because the first argument to `where`
is defined as a `SyntaxType::Block`, and the parser coerces binary expressions
whose left-hand-side looks like a member into a block when the command is
expecting one.

This is mildly more magical than what most programming languages would do,
but we believe that it makes sense to allow commands to fine-tune the syntax
because of the domain nushell is in (command-line shells).

The syntactic expansions supported by this facility are relatively limited.
For example, we don't allow `$it` to become a bare word, simply because the
command asks for a string in the relevant position. That would quickly
become more confusing than it's worth.

This PR adds a new `SyntaxType` rule: `SyntaxType::Path`. When a command
declares a parameter as a `SyntaxType::Path`, string literals and bare
words passed as an argument to that parameter are processed using the
path expansion rules. Right now, that only means that `~` is expanded into
the home directory, but additional rules are possible in the future.

By restricting this expansion to a syntactic expansion when passed as an
argument to a command expecting a path, we avoid making `~` a generally
reserved character. This will also allow us to give good tab completion
for paths with `~` characters in them when a command is expecting a path.

In order to accomplish the above, this commit changes the parsing functions
to take a `Context` instead of just a `CommandRegistry`. From the perspective
of macro expansion, you can think of the `CommandRegistry` as a dictionary
of in-scope macros, and the `Context` as the compile-time state used in
expansion. This could gain additional functionality over time as we find
more uses for the expansion system.
2019-08-26 21:03:24 -07:00
Dirkjan Ochtman
ce0113eb19 Replace use of unstable Option::flatten() with and_then() 2019-08-26 21:26:10 +02:00
Jonathan Turner
6354e0cc55 Remove X11 requirement 2019-08-23 15:29:08 +12:00
Jonathan Turner
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
Jonathan Turner
99671b8ffc Move more parts to tags and away from spans 2019-08-05 20:54:29 +12:00
Yehuda Katz
586aa6bae1 WIP - types check 2019-08-02 19:17:28 -07:00
Yehuda Katz
fc173c46d8 Restructuring 2019-08-02 12:15:07 -07:00
Jonathan Turner
462f783fac initial change to Tagged<Value> 2019-08-01 13:58:42 +12:00
Jonathan Turner
618be5de54 Remove workaround. Need a better one 2019-07-29 20:01:09 +12:00
Jonathan Turner
bd639b52ff bump deps 2019-07-29 19:46:24 +12:00
Jonathan Turner
403f9d2499
Revert "Switch way of doing terminal size calculation" 2019-07-29 16:18:11 +12:00
Jonathan Turner
5a4805d422 Switch way of doing terminal size calculation 2019-07-29 05:34:04 +12:00
Jonathan Turner
c85b7728bc Remove old sysinfo and finish sys 2019-07-28 14:02:42 +12:00
Jonathan Turner
2464a33660 Progress the sys plugin a bit further 2019-07-28 08:09:25 +12:00
Jonathan Turner
1f26101e2f Yet more improvements to textview (and binaryview) 2019-07-26 04:22:22 +12:00
Jonathan Turner
f2873edf6c One more go at fixing scroll textarea in windows 2019-07-25 14:43:51 +12:00
Jonathan Turner
15507f00fc Introduce CallInfo, which abstracts args, name_span, and source_map 2019-07-20 14:27:10 +12:00
Jonathan Turner
3ebb6ba991 Fix plugin's commandconfig 2019-07-16 19:08:35 +12:00
Jonathan Turner
1ecb4401ba WIP 2019-07-16 15:25:36 +12:00
Jonathan Turner
8d920baf07 Try to add hires mode 2019-07-15 06:38:03 +12:00
Jonathan Turner
1a36f47bcb Don't redraw static frame 2019-07-14 19:54:30 +12:00
Jonathan Turner
a3f628427f Fix binary view for better approx 2019-07-14 19:28:56 +12:00
Jonathan Turner
7e555a0ef2 "Add plugin arg errors. Bring remaining errors to parity" 2019-07-14 04:59:59 +12:00
Yehuda Katz
7c2a1c619e Tests pass 2019-07-12 19:20:26 -07:00
Jonathan Turner
ea997289d9 Add some logic for more binary formats 2019-07-05 19:53:09 +12:00
Jonathan Turner
71ac03f287 Improve ansi handling 2019-07-05 16:23:28 +12:00
Jonathan Turner
563fabfdca Small cleanup, hopefull unbroken lock file 2019-07-05 13:01:19 +12:00
Jonathan Turner
73d87e57ab Switch to rawkey reader. Add more binary reading 2019-07-05 10:17:18 +12:00
Jonathan Turner
5e779d8b2b Add pretty binary viewing 2019-07-04 17:23:05 +12:00