Commit Graph

256 Commits

Author SHA1 Message Date
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
Patrick Meredith
87a99bbabf Implement to-bson 2019-08-26 20:07:59 -04:00
Dirkjan Ochtman
ce0113eb19 Replace use of unstable Option::flatten() with and_then() 2019-08-26 21:26:10 +02:00
Dirkjan Ochtman
b77effa434 Fix formatting with cargo fmt 2019-08-26 20:19:05 +02:00
Odin Dutton
bbe7d68659 Return version from clap
This is what `nu --version` uses.
2019-08-26 20:33:28 +10:00
Andrés N. Robalino
12e3806349
Merge pull request #415 from androbtech/fromto-refact
[from|to]csv additions/refactoring.
2019-08-25 12:56:28 -05:00
Jonathan Turner
dda4a707a7
Merge pull request #421 from ramonsnir/reverse
add reverse
2019-08-26 05:41:07 +12:00
Andrés N. Robalino
0e14ba86ae [from|to]csv additions/refactoring.
Introduced flag to tell `from-to` / `to-csv` whether we want headers parsed and/or written.
2019-08-25 12:32:08 -05:00
Ramon Snir
9735c3fcea
add reverse 2019-08-25 12:14:17 -04:00
Patrick Meredith
a75c90cc42 Rebase on master 2019-08-25 10:16:22 -04:00
Patrick Meredith
b0d7daa0d6 Remove cargo culted latest_tag that is not needed for from_bson 2019-08-25 09:50:25 -04:00
Patrick Meredith
a3b4d47b4e Finish last few types and add tests 2019-08-25 09:50:25 -04:00
Patrick Meredith
722e192c14 Implement some more of the bson types 2019-08-25 09:50:25 -04:00
Patrick Meredith
9814eeae30 Remove need for impl Clone on from_bson_bytes_to_value 2019-08-25 09:50:25 -04:00
Patrick Meredith
a0f0372839 Add mostly working BSON support (missing some types) 2019-08-25 09:50:25 -04: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
ac15989bbb
Merge branch 'master' into surf 2019-08-25 17:41:10 +12:00
Jonathan Turner
9c4f94fed5
Merge pull request #402 from ijt/add-last-command
Add `last` filter
2019-08-25 13:00:13 +12:00
Issac Trotts
108f66941b add last command 2019-08-24 15:01:30 -07:00
Dmitry Starostin
19772f82aa
Add --reverse option for sort-by 2019-08-25 00:11:38 +03:00
Jonathan Turner
721a7b159d switch from reqwest to surf 2019-08-25 07:36:19 +12:00
Jonathan Turner
bb794dcfec Add expansion to from-* for lists 2019-08-24 19:38:38 +12:00
Jonathan Turner
0a611266ce Clean up error text 2019-08-24 08:31:14 +12:00
Jonathan Turner
6354e0cc55 Remove X11 requirement 2019-08-23 15:29:08 +12:00
Jonathan Turner
303d27d4b6 Finish adding support for protecting value shells 2019-08-22 16:13:40 +12:00
Jonathan Turner
78ca297e47 WIP 2019-08-22 07:38:09 +12:00
Jonathan Turner
73e3402e2f Merge master 2019-08-22 05:09:23 +12:00
Jonathan Turner
e012e04da0 Disallow fileops on values 2019-08-22 05:03:59 +12:00
Jonathan Turner
3c7ca8c403
Merge pull request #327 from jonathandturner/cleanup_ps
Cleanup unneeded compiler flag
2019-08-22 04:57:25 +12:00
Andrés N. Robalino
c2b377eedc Leave Nu's shell manager to figure out the suitable path for us instead. 2019-08-21 11:23:26 -05:00
Jonathan Turner
8e5744cf9b Cleanup unneeded compiler flag 2019-08-22 04:00:29 +12:00
Andrés N. Robalino
1e8793135a Mark the unwrap and Sweep the unwrap a bit more. 2019-08-21 10:48:04 -05:00
Andrés N. Robalino
8d5fd6f379 Unwrap cleanup mitigation. 2019-08-21 10:08:38 -05:00
Andrés N. Robalino
8b79b28971 mkdir can take multiple directories or multiple directory hierachies and wil create them as required. 2019-08-21 07:07:37 -05:00
Jonathan Turner
23ef76a86b
Update ps.rs 2019-08-21 20:19:36 +12:00
Jonathan Turner
c98bf68341 Oops, one more time 2019-08-21 19:47:33 +12:00
Jonathan Turner
c54528651d Fix ps again 2019-08-21 19:41:18 +12:00
Jonathan Turner
1a74c512ad
Merge pull request #324 from jonathandturner/ps_deps_and_more
Lots of fixes ahead of release
2019-08-21 19:08:01 +12:00
Jonathan Turner
e3e4e30fb3 Lots of fixes ahead of release 2019-08-21 18:39:57 +12:00
Andrés N. Robalino
0f28719564 mv -> More organized method definitions. 2019-08-20 07:35:41 -05:00
Andrés N. Robalino
11095860c8 rm fully operational and error surveyd. 2019-08-20 06:22:11 -05:00
Jonathan Turner
64c129d65f Finish updating the last cases 2019-08-20 18:11:11 +12:00
Jonathan Turner
421aacee76 Merge branch 'master' into implement-whole-stream-command-for-all-commands 2019-08-20 16:13:49 +12:00
Odin Dutton
31790a9906 Use args structs to better extract multiple arguments 2019-08-20 13:15:05 +10:00
Odin Dutton
9951691023 Use NthArgs to better convert to an integer
Using i64 as u64 deserialize isn't implemented yet.
2019-08-20 13:12:31 +10:00
Odin Dutton
82a315f06a Make cd argument optional
`cd` with no arugments changes directory to $HOME.
2019-08-20 13:11:29 +10:00
Odin Dutton
56c04ff5b6 Remove unneeded TODOs
These commands have been confirmed to have no arguments.
2019-08-20 13:11:01 +10:00
Jonathan Turner
953d28ef74 Fix push/pop for shell manager 2019-08-19 20:07:55 +12:00
Jonathan Turner
fef447a659 Fix shell-ring to rotate as expected 2019-08-19 19:29:27 +12:00