Commit Graph

33 Commits

Author SHA1 Message Date
Taiki Endo
58a32490c5 Remove usage of in_band_lifetimes feature 2019-08-30 01:32:31 +09:00
est31
c87fa14fc8 Replace crate visibility identifier with pub(crate)
Result of running:

find src -name *.rs -exec sed -i 's/crate /pub(crate) /g' {} \;
2019-08-29 13:09:09 +02: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
Yehuda Katz
5bfb96447a Reduce unwraps
Remove a number of unwraps. In some cases, a `?` just worked as is. I also made it possible to use `?` to go from Result<OutputStream, ShellError> to OutputStream. Finally, started updating PerItemCommand to be able to use the signature deserialization logic, which substantially reduces unwraps.

This is still in-progress work, but tests pass and it should be clear to merge and keep iterating on master.
2019-08-16 20:53:39 -07:00
Jonathan Turner
efd9631a90 All tests pass 2019-08-15 17:46:19 +12:00
Jonathan Turner
dd18122a24 WIP 2019-08-15 17:02:02 +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
a09361698e Update plugin protocol for begin, and create new sys plugin 2019-07-27 19:45:00 +12:00
Yehuda Katz
73deeb69db Clean up lint errors 2019-07-23 21:10:48 -07:00
Yehuda Katz
5a8e041a48 Tests pass! 2019-07-23 15:22:11 -07:00
Jonathan Turner
2ed46046bd Cleanup for upcoming release 2019-07-17 07:10:25 +12:00
Jonathan Turner
c7abb31b7c Fix inc plugin 2019-07-16 19:25:48 +12:00
Jonathan Turner
3ebb6ba991 Fix plugin's commandconfig 2019-07-16 19:08:35 +12:00
Yehuda Katz
ded3462e82 Make signatures a little more general 2019-07-15 14:16:27 -07: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
Yehuda Katz
2da12aed56 Tests pass 2019-07-12 19:20:26 -07:00
Yehuda Katz
34033afce4 WIP improve error infrastructure
Also simplify commands and reduce papercuts
2019-07-12 19:20:26 -07:00
Jonathan Turner
75ddfe9f5a Add filter and sink plugins 2019-07-02 19:56:20 +12:00
Yehuda Katz
711ed05b43 Produce ArgumentError for signature mismatch
ArgumentError also automatically produces diagnostics
2019-06-29 23:14:40 -07:00
Yehuda Katz
4036bf1ffd &str -> Text 2019-06-22 16:46:16 -04:00
Yehuda Katz
e981129f1f Things work 2019-06-21 21:36:57 -04:00
Jonathan Turner
e94d1d2758 Add pretty errors to commands 2019-06-08 10:35:07 +12:00
Yehuda Katz
324f7915be Span all the things
Also set up builder infra for more consistent AST creation.
2019-06-05 23:34:59 -07:00
Yehuda Katz
f3bb4a03c2 Improve parser 2019-06-04 14:42:31 -07:00
Yehuda Katz
b9159f033b Parsing tests 2019-06-02 09:28:40 -07:00
Yehuda Katz
69effbc9e7 Improve signature infrastructure
The `config` command uses different kinds of named arguments, which
illustrates how it works.
2019-05-31 22:54:15 -07:00
Yehuda Katz
d5255f6dbf
Evaluator MVP (#39)
Evaluator, MVP
2019-05-27 23:45:18 -07:00
Yehuda Katz
b74daa2e60 A real parser (lalrpop) 2019-05-26 00:17:35 -07:00