Commit Graph

1757 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
Jonathan Turner
5313fc5568
Merge pull request #477 from jonathandturner/fix_dbg_release
Fix having to clean directories when switching between release and debug
2019-08-27 14:11:30 +12:00
Andrés N. Robalino
505fadd6d1
Merge pull request #476 from pmeredit/topic/to_bson
Implement to-bson
2019-08-26 20:52:45 -05:00
Jonathan Turner
716517c13f Fix having to clean directories when switching between release and debug 2019-08-27 13:46:38 +12:00
Patrick Meredith
738675259e Improve test so that it should work on Windows 2019-08-26 21:26:49 -04:00
Patrick Meredith
87a99bbabf Implement to-bson 2019-08-26 20:07:59 -04:00
Andrés N. Robalino
e32291d0d7
Merge pull request #473 from androbtech/history
Avoid panicking if history can't be saved.
2019-08-26 18:47:07 -05:00
Andrés N. Robalino
3e699db57c Aviso. 2019-08-26 17:41:57 -05:00
Andrés N. Robalino
91093f2ab2 Avoid panicking if history can't be saved. 2019-08-26 17:18:38 -05:00
Jonathan Turner
69492a10fe
Merge pull request #468 from djc/unflattening
Replace use of unstable Option::flatten() with and_then()
2019-08-27 09:27:27 +12:00
Dirkjan Ochtman
ce0113eb19 Replace use of unstable Option::flatten() with and_then() 2019-08-26 21:26:10 +02:00
Jonathan Turner
ca11dc2031
Merge pull request #464 from djc/fmt
Fix formatting with cargo fmt
2019-08-27 07:12:18 +12:00
Dirkjan Ochtman
b77effa434 Fix formatting with cargo fmt 2019-08-26 20:19:05 +02:00
Jonathan Turner
3514c77aac
Merge pull request #459 from BatmanAoD/WinBatchFiles
Permit use of Windows Batch files
2019-08-27 05:47:24 +12:00
Kyle Strand
9a31a6c296 Permit use of Windows Batch files 2019-08-26 11:17:47 -06:00
Jonathan Turner
d51e12c69d
Merge pull request #453 from twe4ked/pull-version-from-clap
Return version from clap
2019-08-27 03:43:23 +12:00
Oskar Skog
8445cda291 Preserve empty columns if separator isn't whitespace
#394
2019-08-26 15:00:27 +03:00
Odin Dutton
bbe7d68659 Return version from clap
This is what `nu --version` uses.
2019-08-26 20:33:28 +10:00
Jonathan Turner
628da27122
Merge pull request #448 from jonathandturner/fix_build
Fix the build
2019-08-26 19:10:57 +12: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
Jonathan Turner
8ff418dc00
Merge pull request #349 from Porges/box-drawing
Use Unicode box-drawing characters for tables
2019-08-26 17:57:48 +12: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
Vanessa Sochat
ec0bc00253
adding dockerfile
Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>
2019-08-25 17:56:49 -04: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
George Pollard
cce5b5bb5e
Revert ellipsis changes 2019-08-25 20:00:04 +12: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