Commit Graph

777 Commits

Author SHA1 Message Date
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
Andrés N. Robalino
8da82c79b8
Merge pull request #444 from androbtech/master
mark #[test] back. (deleted and reverting it from.. 12e38063)
2019-08-25 22:15:31 -05:00
Andrés N. Robalino
8940e57cf3 mark #[test] back. (deleted and reverting it from.. 12e38063) 2019-08-25 21:50:55 -05:00
Yehuda Katz
9761621879
Create CODE_OF_CONDUCT.md
I put my own email address in here as a placeholder, but we should change it to conduct@nushell.sh as soon as possible.

Closes #251
2019-08-25 19:19:47 -07:00
Jonathan Turner
30187e0311
Update README.md 2019-08-26 11:47:35 +12:00
Jonathan Turner
7639fac1e7
Merge pull request #433 from yaahc/master
Make it more obvious that nightly is required
2019-08-26 11:10:14 +12:00
Jonathan Turner
f911e63765
Merge pull request #432 from nushell/jonathandturner-patch-2
Fix build by pinning futures-async-stream
2019-08-26 11:07:05 +12:00
Jane Lusby
04d2371cd6 Make it more obvious that nightly is required 2019-08-25 15:45:12 -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
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
Andrés N. Robalino
de930daf33
Merge pull request #398 from pmeredit/topic/support_bson
Topic/support bson
2019-08-25 11:58:28 -05:00
Patrick Meredith
3c89cb7e98 Remove test that refuses to pass on Windows (it's just a minor formatting issue) 2019-08-25 12:25:40 -04:00
Ramon Snir
9735c3fcea
add reverse 2019-08-25 12:14:17 -04:00
Patrick Meredith
376809aa2a Normalize strings for bson tests 2019-08-25 11:43:15 -04:00
Patrick Meredith
a75c90cc42 Rebase on master 2019-08-25 10:16:22 -04:00
Patrick Meredith
c967f15e7c Fix tests 2019-08-25 09:50:25 -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
e9673c31ea Remove redundant test 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
dd74657385
Merge pull request #410 from jonathandturner/fix_a_few_issues
Fix a few issues with textview and the parser
2019-08-25 19:41:04 +12:00
Jonathan Turner
439700b87c Fix a few issues with textview and the parser 2019-08-25 19:15:56 +12:00
Jonathan Turner
5a355683ad
Merge pull request #397 from jonathandturner/surf
switch from reqwest to surf
2019-08-25 18:20:19 +12:00
Jonathan Turner
ac15989bbb
Merge branch 'master' into surf 2019-08-25 17:41:10 +12:00
Jonathan Turner
6e05f5c8da Merge branch 'surf' of github.com:jonathandturner/nushell into surf 2019-08-25 17:39:53 +12:00
Jonathan Turner
25750f8bb0 Bump the mac image version 2019-08-25 17:39:37 +12:00
Jonathan Turner
d5656d221b
Update Cargo.toml 2019-08-25 14:55:17 +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
45d514a4cb sort to get test to pass on linux 2019-08-24 17:21:09 -07:00
Jonathan Turner
88fded8c64
Update Cargo.toml 2019-08-25 10:19:19 +12:00
Issac Trotts
108f66941b add last command 2019-08-24 15:01:30 -07:00
Jonathan Turner
a85f2b9fa1
Update Cargo.toml 2019-08-25 10:00:55 +12:00
Issac Trotts
af2439e880 add test 2019-08-24 14:56:56 -07:00
Jonathan Turner
5d34e3a37d
Merge pull request #381 from vthriller/ensure-nightly
Enforce nightly toolchain
2019-08-25 09:56:08 +12:00
Jonathan Turner
236e9ac81e
Merge pull request #399 from incrop/sort-by-reverse
Add --reverse option for sort-by
2019-08-25 09:51:25 +12:00
Jonathan Turner
190ca32161
Merge pull request #401 from eoinkelly/patch-1
Fix typo in README
2019-08-25 09:50:11 +12:00
Eoin Kelly
c80907b7e6
Fix typo 2019-08-25 09:48:02 +12:00
Dmitry Starostin
19772f82aa
Add --reverse option for sort-by 2019-08-25 00:11:38 +03:00
vthriller
4e59d30c83 azure-pipelines: use rust version defined in rust-toolchain file 2019-08-24 23:03:49 +03:00
vthriller
f69f0b9c62 Enforce nightly toolchain
This code and some of its dependencies (like futures-async-stream) rely on #[feature()], so it doesn't make sense to build this with stable compiler.
2019-08-24 23:03:31 +03:00
Jonathan Turner
1b863cbb2b
Merge pull request #396 from est31/update_readme
There is no dependency on libssl on mac os any more
2019-08-25 08:00:24 +12:00
Jonathan Turner
721a7b159d switch from reqwest to surf 2019-08-25 07:36:19 +12:00
est31
b777cf9008 There is no dependency on libssl on mac os any more 2019-08-24 21:32:28 +02:00
Jonathan Turner
ad8589e5a2
Merge pull request #382 from devnought/master
use `clap::crate_version!()`, remove async feature
2019-08-25 07:22:38 +12:00
Kyle Gretchev
b36bda24fa use clap::crate_version!()
- `crate_version()!` will pull version from Cargo.toml
2019-08-24 12:38:18 -04:00