Commit Graph

518 Commits

Author SHA1 Message Date
3d147d1143 Add SQLite support 2019-08-30 20:54:45 -04:00
f1e8c433c2 [from/to]tsv support. 2019-08-29 04:02:16 -05:00
9810df25b4 Readability improvement. 2019-08-29 01:31:56 -05:00
4d2b0f43f5 Fix test. 2019-08-28 21:05:23 -05:00
a07817e0e0 cover pipeline helper. 2019-08-28 20:30:51 -05:00
55fb1f8dda Yo quiero Playground taconushell. 2019-08-28 19:32:42 -05:00
f82cc4291f Migrate commands_test 2019-08-28 10:58:00 -07:00
abac7cf746 Migrate rm 2019-08-28 10:48:52 -07:00
2c65b2fc2f Migrate mv 2019-08-28 10:28:58 -07:00
21ad06b1e1 Remove unwraps and clean up playground
The original intent of this patch was to remove more unwraps to reduce
panics. I then lost a ton of time to the fact that the playground isn't
in a temp directory (because of permissions issues on Windows).

This commit improves the test facilities to:

- use a tempdir for the playground
- change the playground API so you instantiate it with a block that
  encloses the lifetime of the tempdir
- the block is called with a `dirs` argument that has `dirs.test()` and
  other important directories that we were computing by hand all the time
- the block is also called with a `playground` argument that you can use
  to construct files (it's the same `Playground` as before)
- change the nu! and nu_error! macros to produce output instead of
  taking a variable binding
- change the nu! and nu_error! macros to do the cwd() transformation
  internally
- change the nu! and nu_error! macros to take varargs at the end that
  get interpolated into the running command

I didn't manage to finish porting all of the tests, so a bunch of tests
are currently commented out. That will need to change before we land
this patch.
2019-08-28 10:01:16 -07:00
162c8b4274 swept clean quotes 2019-08-27 06:20:22 -05:00
b502954558 [from|to]json additions/refactoring. 2019-08-27 06:05:51 -05:00
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
738675259e Improve test so that it should work on Windows 2019-08-26 21:26:49 -04:00
87a99bbabf Implement to-bson 2019-08-26 20:07:59 -04:00
b77effa434 Fix formatting with cargo fmt 2019-08-26 20:19:05 +02:00
8940e57cf3 mark #[test] back. (deleted and reverting it from.. 12e38063) 2019-08-25 21:50:55 -05:00
12e3806349 Merge pull request #415 from androbtech/fromto-refact
[from|to]csv additions/refactoring.
2019-08-25 12:56:28 -05:00
dda4a707a7 Merge pull request #421 from ramonsnir/reverse
add reverse
2019-08-26 05:41:07 +12:00
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
3c89cb7e98 Remove test that refuses to pass on Windows (it's just a minor formatting issue) 2019-08-25 12:25:40 -04:00
9735c3fcea add reverse 2019-08-25 12:14:17 -04:00
376809aa2a Normalize strings for bson tests 2019-08-25 11:43:15 -04:00
e9673c31ea Remove redundant test 2019-08-25 09:50:25 -04:00
a3b4d47b4e Finish last few types and add tests 2019-08-25 09:50:25 -04:00
9c4f94fed5 Merge pull request #402 from ijt/add-last-command
Add `last` filter
2019-08-25 13:00:13 +12:00
45d514a4cb sort to get test to pass on linux 2019-08-24 17:21:09 -07:00
108f66941b add last command 2019-08-24 15:01:30 -07:00
af2439e880 add test 2019-08-24 14:56:56 -07:00
19772f82aa Add --reverse option for sort-by 2019-08-25 00:11:38 +03:00
8b79b28971 mkdir can take multiple directories or multiple directory hierachies and wil create them as required. 2019-08-21 07:07:37 -05:00
8c1d4ed91a sidestep 'enter' integration test failure for files. 2019-08-20 08:01:02 -05:00
0f28719564 mv -> More organized method definitions. 2019-08-20 07:35:41 -05:00
11095860c8 rm fully operational and error surveyd. 2019-08-20 06:22:11 -05:00
308323426d Covered enter's ability to enter files other than filesystems. 2019-08-20 03:11:33 -05:00
51ec48f357 Update enter test 2019-08-20 04:40:47 +12:00
953d28ef74 Fix push/pop for shell manager 2019-08-19 20:07:55 +12:00
5dd20850b5 Refactoring and unwrap cleanup beginnings. 2019-08-18 20:28:55 -05:00
0dc4b2b686 Add support for external escape valve (^dir)
This commit makes it possible to force nu to treat a command as an external command by prefixing it with `^`. For example `^dir` will force `dir` to run an external command, even if `dir` is also a registered nu command.

This ensures that users don't need to leave nu just because we happened to use a command they need.

This commit adds a new token type for external commands, which, among other things, makes it pretty straight forward to syntax highlight external commands uniquely, and generally to treat them as special.
2019-08-15 15:18:18 -07:00
024f0915a3 Shellring traversal and filesystem environment retention per session confirmed. 2019-08-15 02:10:33 -05:00
75e3c6f547 copies_expected -> expected. Use expected as test dirname expectation outcomes from now on. 2019-08-14 16:05:35 -05:00
121237ee4b Reverted test removal from (dfcbaed) 2019-08-14 15:55:26 -05:00
154063013f mv introduced. \¡Viva\! 2019-08-14 15:29:05 -05:00
dfcbaed1c6 More descriptive test playground names for commands other than the basic ones. 2019-08-14 15:29:05 -05:00
278de0e517 cp refactoring. 2019-08-14 15:29:05 -05:00
6cf3dc92fc Add support for utf16 files 2019-08-12 16:11:42 +12:00
fc38603de8 Test sample changed to check behavior with strings on different operating systems. 2019-08-11 13:18:42 -05:00
cee2f5207e Str plugin: replace & find-replace. 2019-08-11 12:46:14 -05:00
21ab65979f Covered the remaining semver flags for inc plugin. 2019-08-10 06:04:13 -05:00