Commit Graph

888 Commits

Author SHA1 Message Date
Jonathan Turner
550bda477b
Merge pull request #1060 from naufraghi/issues-972-expand-tilde-as-home-in-external-commands
Expand tilde as home in external commands
2019-12-13 08:46:08 -08:00
Matteo Bertini
219b7e64cd Use shellexpand to expand ~ in external commands
Add tests for ~tilde expansion:

- test that "~" is expanded (no more "~" in output)
- ensure that "1~1" is not expanded to "1/home/user1" as it was
  before

Fixes #972

Note: the first test does not check the literal expansion because
the path on Windows is expanded as a Linux path, but the correct
expansion may come for free once `shellexpand` will use the `dirs`
crate too (https://github.com/netvl/shellexpand/issues/3).
2019-12-13 11:54:41 +01:00
Yehuda Katz
e8800fdd0c Remove the coloring_in_tokens feature flag
Stabilize and enable
2019-12-12 11:34:43 -08:00
Yehuda Katz
57af9b5040 Add Range and start Signature support
This commit contains two improvements:

- Support for a Range syntax (and a corresponding Range value)
- Work towards a signature syntax

Implementing the Range syntax resulted in cleaning up how operators in
the core syntax works. There are now two kinds of infix operators

- tight operators (`.` and `..`)
- loose operators

Tight operators may not be interspersed (`$it.left..$it.right` is a
syntax error). Loose operators require whitespace on both sides of the
operator, and can be arbitrarily interspersed. Precedence is left to
right in the core syntax.

Note that delimited syntax (like `( ... )` or `[ ... ]`) is a single
token node in the core syntax. A single token node can be parsed from
beginning to end in a context-free manner.

The rule for `.` is `<token node>.<member>`. The rule for `..` is
`<token node>..<token node>`.

Loose operators all have the same syntactic rule: `<token
node><space><loose op><space><token node>`.

The second aspect of this pull request is the beginning of support for a
signature syntax. Before implementing signatures, a necessary
prerequisite is for the core syntax to support multi-line programs.

That work establishes a few things:

- `;` and newlines are handled in the core grammar, and both count as
  "separators"
- line comments begin with `#` and continue until the end of the line

In this commit, multi-token productions in the core grammar can use
separators interchangably with spaces. However, I think we will
ultimately want a different rule preventing separators from occurring
before an infix operator, so that the end of a line is always
unambiguous. This would avoid gratuitous differences between modules and
repl usage.

We already effectively have this rule, because otherwise `x<newline> |
y` would be a single pipeline, but of course that wouldn't work.
2019-12-11 16:41:07 -08:00
Jonathan Turner
1dcbd89a89 Trying this as a workaround to the [[bin]] issue 2019-12-10 16:57:55 +13:00
Jonathan Turner
e2a95c3e1d Move str and inc to core plugins 2019-12-10 13:59:13 +13:00
Jonathan Turner
88f899d341 Move some plugins back to being core shippable plugins 2019-12-10 13:05:40 +13:00
Jonathan Turner
fd6ee03391 Remove old ValueExt 2019-12-10 07:52:01 +13:00
Jonathan Turner
9f702fe01a Move the remainder of the plugins to crates 2019-12-10 07:39:51 +13:00
Jonathan Turner
38cbfdb8a9 Remove partial docker plugin. Embed->wrap 2019-12-09 17:41:09 +13:00
Jonathan Turner
e98ed1b43d Move format/parse to core commands 2019-12-09 15:04:13 +13:00
Jonathan Turner
251c3e103d Move format/parse to core commands 2019-12-09 14:57:53 +13:00
Jonathan Turner
0515ed976c Fix panic 2019-12-09 05:36:24 +13:00
Jonathan Turner
f653992b4a A little cleanup 2019-12-08 19:42:43 +13:00
Jonathan Turner
b5f8c1cc50 param completions work now 2019-12-08 19:23:31 +13:00
Jonathan Turner
f9a46ce1e7 WIP param completions 2019-12-08 19:04:23 +13:00
Jonathan Turner
b6ba7f97fd WIP param completions 2019-12-08 18:58:53 +13:00
Thibaut Brandscheid
683f4c35d9 Fix more Clippy warnings
cargo clippy -- -W clippy::correctness
2019-12-07 21:04:58 +01:00
Thibaut Brandscheid
04b214bef6 split format/table::from_list into multiple functions 2019-12-07 14:52:52 +01:00
Jonathan Turner
d07dc57537 Add missing fallback case 2019-12-07 19:24:58 +13:00
Jonathan Turner
d0a2888e88 Finish adding makeshift support for to fetch/post plugins 2019-12-07 17:23:59 +13:00
Jonathan Turner
cec2eff933 Merge branch 'master' into fetch_post 2019-12-07 16:53:50 +13:00
Jonathan Turner
38b7a3e32b WIP move post/fetch to plugins 2019-12-07 16:46:05 +13:00
Thibaut Brandscheid
cde92a9fb9 Fix most Clippy performance warnings
command used: cargo clippy -- -W clippy::perf
2019-12-06 23:25:47 +01:00
Jonathan Turner
768adb84a4 Remove commented out region 2019-12-06 09:19:24 +13:00
Jonathan Turner
26b0250e22 Remove commented out region 2019-12-06 09:18:16 +13:00
Jonathan Turner
6893850fce Move edit and insert to core 2019-12-06 09:15:41 +13:00
Jonathan Turner
1d5f13ddca formatting 2019-12-05 08:57:03 +13:00
Jonathan Turner
d12c16a331 Extract ps and sys subcrates. Move helper methods to UntaggedValue 2019-12-05 08:52:31 +13:00
Jonathan Turner
a4bb5d4ff5 Move binaryview to a sub-crate 2019-12-05 06:51:20 +13:00
Sebastian Jung
59510a85d1 fix build warnings 2019-12-04 17:13:21 +01:00
Sebastian Jung
ecebe1314a update to new crates structure 2019-12-03 20:56:39 +01:00
Sebastian Jung
bda5db59c8 Merge remote-tracking branch 'upstream/master' into range 2019-12-03 20:23:49 +01:00
Andrés N. Robalino
4526d757b6
Merge pull request #1049 from andrasio/embed-list
embed as column when embedding a list
2019-12-03 02:51:58 -05:00
Andrés N. Robalino
e5405d7f5c embed as column when embedding a list 2019-12-03 02:26:01 -05:00
Sebastian Jung
201506a5ad add tests for range + run rustfmt 2019-12-03 08:24:49 +01:00
Jonathan Turner
efc879b955 Add new line primitive, bump version, allow bare filepaths 2019-12-03 19:44:59 +13:00
Sebastian Jung
8390cc97e1 add range command 2019-12-02 20:15:14 +01:00
Yehuda Katz
4115634bfc Try to re-apply #1039 2019-12-02 11:02:58 -08:00
Jonathan Turner
8a0bdde17a Remove env var from starship 2019-12-02 11:02:58 -08:00
Yehuda Katz
a1e21828d6 Fix tests 2019-12-02 11:02:57 -08:00
Jonathan Turner
0f193c2337 Update histogram.rs 2019-12-02 11:02:57 -08:00
Yehuda Katz
526d94d862 improve duration print
original commit: ddb9d3a864
2019-12-02 11:02:57 -08:00
Andrés N. Robalino
2fdafa52b1 replace and find-replace str plugin additions. 2019-12-02 11:02:57 -08:00
Yehuda Katz
f52c0655c7 expand tilde in externals
original: 9f42d7693f
2019-12-02 11:02:57 -08:00
Jason Gedge
4e9afd6698 Refactor classified.rs into separate modules.
Adds modules for internal, external, and dynamic commands, as well as
the pipeline functionality. These are exported as their old names from
the classified module so as to keep its "interface" the same.
2019-12-02 11:02:57 -08:00
Belhorma Bendebiche
8f9dd6516e Add =~ and !~ operators on strings
`left =~ right` return true if left contains right, using Rust's
`String::contains`. `!~` is the negated version.

A new `apply_operator` function is added which decouples evaluation from
`Value::compare`. This returns a `Value` and opens the door to
implementing `+` for example, though it wouldn't be useful immediately.

The `operator!` macro had to be changed slightly as it would choke on
`~` in arguments.
2019-12-02 11:02:57 -08:00
Yehuda Katz
e4226def16 Extract core stuff into own crates
This commit extracts five new crates:

- nu-source, which contains the core source-code handling logic in Nu,
  including Text, Span, and also the pretty.rs-based debug logic
- nu-parser, which is the parser and expander logic
- nu-protocol, which is the bulk of the types and basic conveniences
  used by plugins
- nu-errors, which contains ShellError, ParseError and error handling
  conveniences
- nu-textview, which is the textview plugin extracted into a crate

One of the major consequences of this refactor is that it's no longer
possible to `impl X for Spanned<Y>` outside of the `nu-source` crate, so
a lot of types became more concrete (Value became a concrete type
instead of Spanned<Value>, for example).

This also turned a number of inherent methods in the main nu crate into
plain functions (impl Value {} became a bunch of functions in the
`value` namespace in `crate::data::value`).
2019-12-02 10:54:12 -08:00
Jason Gedge
ac5543bad9 Move pipeline execution code into classified::Pipeline 2019-11-30 16:12:34 -05:00
Jonathan Turner
0a93335f6d Remove env var from starship 2019-11-30 08:38:44 +13:00