Commit Graph

30 Commits

Author SHA1 Message Date
3750a04cfc Merge branch 'master' into expand-tilde 2019-08-27 16:23:56 +12:00
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
ce0113eb19 Replace use of unstable Option::flatten() with and_then() 2019-08-26 21:26:10 +02:00
6354e0cc55 Remove X11 requirement 2019-08-23 15:29:08 +12:00
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
99671b8ffc Move more parts to tags and away from spans 2019-08-05 20:54:29 +12:00
586aa6bae1 WIP - types check 2019-08-02 19:17:28 -07:00
fc173c46d8 Restructuring 2019-08-02 12:15:07 -07:00
462f783fac initial change to Tagged<Value> 2019-08-01 13:58:42 +12:00
618be5de54 Remove workaround. Need a better one 2019-07-29 20:01:09 +12:00
bd639b52ff bump deps 2019-07-29 19:46:24 +12:00
403f9d2499 Revert "Switch way of doing terminal size calculation" 2019-07-29 16:18:11 +12:00
5a4805d422 Switch way of doing terminal size calculation 2019-07-29 05:34:04 +12:00
c85b7728bc Remove old sysinfo and finish sys 2019-07-28 14:02:42 +12:00
2464a33660 Progress the sys plugin a bit further 2019-07-28 08:09:25 +12:00
1f26101e2f Yet more improvements to textview (and binaryview) 2019-07-26 04:22:22 +12:00
f2873edf6c One more go at fixing scroll textarea in windows 2019-07-25 14:43:51 +12:00
15507f00fc Introduce CallInfo, which abstracts args, name_span, and source_map 2019-07-20 14:27:10 +12:00
3ebb6ba991 Fix plugin's commandconfig 2019-07-16 19:08:35 +12:00
1ecb4401ba WIP 2019-07-16 15:25:36 +12:00
8d920baf07 Try to add hires mode 2019-07-15 06:38:03 +12:00
1a36f47bcb Don't redraw static frame 2019-07-14 19:54:30 +12:00
a3f628427f Fix binary view for better approx 2019-07-14 19:28:56 +12:00
7e555a0ef2 "Add plugin arg errors. Bring remaining errors to parity" 2019-07-14 04:59:59 +12:00
7c2a1c619e Tests pass 2019-07-12 19:20:26 -07:00
ea997289d9 Add some logic for more binary formats 2019-07-05 19:53:09 +12:00
71ac03f287 Improve ansi handling 2019-07-05 16:23:28 +12:00
563fabfdca Small cleanup, hopefull unbroken lock file 2019-07-05 13:01:19 +12:00
73d87e57ab Switch to rawkey reader. Add more binary reading 2019-07-05 10:17:18 +12:00
5e779d8b2b Add pretty binary viewing 2019-07-04 17:23:05 +12:00