Commit Graph

130 Commits

Author SHA1 Message Date
est31
a7d4a8b065 Make neso dependency optional 2019-08-29 01:38:48 +02:00
est31
7ca95ba9dd Remove unused prettyprint dependency 2019-08-29 01:38:39 +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
Jonathan Turner
472ff74904
Fix build by pinning futures-async-stream
This pins futures-async-stream to fix the current build failure
2019-08-26 10:42:26 +12:00
Patrick Meredith
93a1a0604e Update how extensions are set to default to path when no extension can be determined from mime 2019-08-25 09:50:25 -04:00
Jonathan Turner
721a7b159d switch from reqwest to surf 2019-08-25 07:36:19 +12:00
est31
bd2be874c1 Remove unused unicode-width dependency 2019-08-24 15:57:44 +02:00
est31
651589164a Remove unused strip-ansi-escapes dependency 2019-08-24 15:55:18 +02:00
est31
f893ef03d6 Remove unused derive_more dependency 2019-08-24 15:52:27 +02:00
est31
ba602c4629 Remove unused lazy_static dependency 2019-08-24 15:51:54 +02:00
est31
4fb298aae0 Remove unused adhoc_derive dependency 2019-08-24 15:50:16 +02:00
est31
c811cbe821 Remove unused enum_derive dependency 2019-08-24 15:48:17 +02:00
est31
62e705079e Remove unused logos and logos_derive dependencies 2019-08-24 15:46:53 +02:00
est31
6e135cbc74 Remove unused async_trait dependency 2019-08-24 15:44:13 +02:00
est31
f6cf6f6768 Remove unused chrono-tz dependency 2019-08-24 15:42:28 +02:00
est31
aa9685e9a3 Also remove toml-query as it's not used 2019-08-24 09:58:25 +02:00
est31
9593007fea Remove unused tempdir dependency 2019-08-24 09:49:36 +02:00
Tom Forbes
9e2fc1c06d
Disable default git2 features 2019-08-23 23:59:05 +01:00
Jonathan Turner
eea1a576c2
Update Cargo.toml 2019-08-23 17:36:52 +12:00
Jonathan Turner
d7b47d89f5
Update Cargo.toml 2019-08-23 17:28:30 +12:00
Jonathan Turner
6354e0cc55 Remove X11 requirement 2019-08-23 15:29:08 +12:00
Jonathan Turner
e3e4e30fb3 Lots of fixes ahead of release 2019-08-21 18:39:57 +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
123b1856c8 Attempt heuristic table 2019-08-13 19:45:31 +12:00
Jonathan Turner
20b909e316
Switch to rustyline git 2019-08-12 05:18:48 +12:00
Jonathan Turner
8e652850dc add some battery stats 2019-08-11 15:01:09 +12:00
Jonathan Turner
e19c618ac5
Revert "Rewrite the ps command" 2019-08-11 13:41:21 +12:00
Jonathan Turner
7c2fec5851 Rewrite the ps command 2019-08-11 11:09:40 +12:00
Jonathan Turner
894958d5e8 Improve sys a bit 2019-08-11 10:13:03 +12:00
Jonathan Turner
1662824a5c Revert bump 2019-08-10 18:31:31 +12:00
Jonathan Turner
60e7dfcf1b Add back command completions 2019-08-10 17:02:15 +12:00
Jonathan Turner
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
Jonathan Turner
bcd9d2d1a6 Pin semver breaking dep 2019-08-09 05:33:19 +12:00
Jonathan Turner
730345086b
Update Cargo.toml 2019-08-09 04:40:28 +12:00
Jonathan Turner
c231dd32cd
Multi shells (#254)
Add multi-shells
2019-08-08 05:49:11 +12:00
Yehuda Katz
fc173c46d8 Restructuring 2019-08-02 12:15:07 -07:00
Jonathan Turner
c42369f1f6 Move off of git deps 2019-08-02 15:58:10 +12:00
Andrés N. Robalino
375f311331 Wildcard support adventure starting with rm command. 2019-08-01 16:01:53 -05:00
Jonathan Turner
509dfe72a8 Switch to rustyline nightly 2019-07-31 05:57:22 +12:00
Jonathan Turner
a8cb395bf1
Merge pull request #227 from jonathandturner/bump
Bump deps
2019-07-29 20:17:01 +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
Andrés N. Robalino
59dec999b8 string utils plugin baseline. 2019-07-28 02:01:32 -05:00
Jonathan Turner
a09361698e Update plugin protocol for begin, and create new sys plugin 2019-07-27 19:45:00 +12:00
Jonathan Turner
e4797f8895 Add end_plugin and sum 2019-07-27 06:40:00 +12:00
Jonathan Turner
1f26101e2f Yet more improvements to textview (and binaryview) 2019-07-26 04:22:22 +12:00
Jonathan Turner
f3fdda8d35 Move textview to plugin 2019-07-25 05:14:30 +12:00
Jonathan Turner
568931c80c add basic paging to text views 2019-07-24 19:44:12 +12:00