Commit Graph

54 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
Jonathan Turner
1cdfe358c2 Fix the utf-8 width calculation 2019-08-27 18:06:30 +12: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
Jonathan Turner
033cae2464 Fix the build 2019-08-26 18:42:14 +12:00
Jonathan Turner
bc91c7f8b1
Merge pull request #355 from Porges/align-bytes
Improve formatting of numeric values (float, int, bytes)
2019-08-26 17:58:48 +12:00
George Pollard
cce5b5bb5e
Revert ellipsis changes 2019-08-25 20:00:04 +12:00
George Pollard
877bbcd931
Remove unused import 2019-08-24 17:38:32 +12:00
George Pollard
c67d4a6eff
Rework implementation method 2019-08-24 17:31:50 +12:00
George Pollard
9de0b27867
Use Unicode box-drawing characters for tables 2019-08-24 14:12:35 +12:00
Jonathan Turner
ec7d159c83 Switch to constraint solving the table 2019-08-17 08:03:29 +12:00
Jonathan Turner
8a66a000e4 Add more polish to table wrap 2019-08-17 04:32:35 +12:00
Jonathan Turner
ffd60bb3af Remove stray println 2019-08-16 17:56:23 +12:00
Jonathan Turner
eb6e24c220 Wrap table cells as needed 2019-08-16 17:47:47 +12:00
Jonathan Turner
785536983a
Revert "Heuristic table view" 2019-08-16 04:49:07 +12:00
Jonathan Turner
156e72f694 Finish up heuristic for table printing 2019-08-14 04:33:59 +12:00
Jonathan Turner
123b1856c8 Attempt heuristic table 2019-08-13 19:45:31 +12:00
Jonathan Turner
3d5395fdd5 Add from_array and improve array viewing 2019-08-12 17:51:13 +12:00
Jonathan Turner
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
Yehuda Katz
586aa6bae1 WIP - types check 2019-08-02 19:17:28 -07:00
Jonathan Turner
462f783fac initial change to Tagged<Value> 2019-08-01 13:58:42 +12:00
Jonathan Turner
a165b3574f Add some row numbers if there are multiple rows 2019-07-20 21:23:44 +12:00
Jonathan Turner
2ed46046bd Cleanup for upcoming release 2019-07-17 07:10:25 +12:00
Yehuda Katz
b2d48566ba Remove unused tree 2019-07-12 19:20:26 -07:00
Yehuda Katz
7c2a1c619e Tests pass 2019-07-12 19:20:26 -07:00
Yehuda Katz
7b68739b52 WIP 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
65a0d27c8a Add binary type and tree sink 2019-07-04 17:11:56 +12:00
Jonathan Turner
0180769971 WIP now load plugins automatically 2019-07-04 05:37:09 +12:00
Jonathan Turner
af82f44e13 Merge master, fix conflicts 2019-06-24 05:54:02 +12:00
Yehuda Katz
d0860837d2 Merge branch 'nom2' into nom4 2019-06-22 18:20:13 -04:00
Yehuda Katz
4036bf1ffd &str -> Text 2019-06-22 16:46:16 -04:00
Jonathan Turner
62310caa32 now tableview forces being a table 2019-06-21 19:52:15 +12:00
Jonathan Turner
18e39343ad Add vertical table view 2019-06-21 16:20:06 +12:00
Jonathan Turner
f40089f29b Better cd and ls 2019-06-14 09:47:25 +12:00
Jonathan Turner
e94d1d2758 Add pretty errors to commands 2019-06-08 10:35:07 +12:00
Jonathan Turner
7c794dc189 Add tree sink 2019-06-07 19:50:26 +12:00
Jonathan Turner
090ec031a9 Add sinks 2019-06-07 18:34:42 +12:00
Jonathan Turner
3a3479e6b5 More table tweaks 2019-06-05 15:54:34 +12:00
Jonathan Turner
c6033424ae Rework table view 2019-06-05 15:27:31 +12:00
Yehuda Katz
f3bb4a03c2 Improve parser 2019-06-04 14:42:31 -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
Yehuda Katz
bd055f2af1 Linting and other cleanup 2019-05-24 12:35:22 -07:00
Yehuda Katz
9f8d2a4de5 Pipe external to internal
Each line is a string object
2019-05-24 11:48:33 -07:00
Yehuda Katz
625a356361 Data flows across commands via streams now 2019-05-23 00:23:06 -07:00
Yehuda Katz
31dd579d6f Small restructuring 2019-05-22 21:30:43 -07:00
Yehuda Katz
af1963d148 Remove dead code 2019-05-15 15:58:44 -07:00