Commit Graph

19 Commits

Author SHA1 Message Date
Yehuda Katz
f70c6d5d48 Extract nu_source into a crate
This commit extracts Tag, Span, Text, as well as source-related debug
facilities into a new crate called nu_source.

This change is much bigger than one might have expected because the
previous code relied heavily on implementing inherent methods on
`Tagged<T>` and `Spanned<T>`, which is no longer possible.

As a result, this change creates more concrete types instead of using
`Tagged<T>`. One notable example: Tagged<Value> became Value, and Value
became UntaggedValue.

This change clarifies the intent of the code in many places, but it does
make it a big change.
2019-11-25 07:37:33 -08:00
Jonathan Turner
fbd980f8b0 Add descriptions to arguments 2019-10-28 18:15:35 +13:00
Yehuda Katz
ab915f1c44 Revert "Revert "Migrate most uses of the Span concept to Tag""
This reverts commit bee7c5639c.
2019-09-14 11:30:24 -05:00
Jonathan Turner
bee7c5639c
Revert "Migrate most uses of the Span concept to Tag" 2019-09-11 19:53:05 +12:00
Yehuda Katz
58b7800172 Migrate most uses of the Span concept to Tag
Also migrate mv, rm and commands like that to taking a
SyntaxType::Pattern instead of a SyntaxType::Path for their first
argument.
2019-09-10 20:41:03 -07:00
Andrés N. Robalino
ca0c6eaf58 This commit introduces a basic help feature. We can go to it
with the `help` command to explore and list all commands available.

Enter will also try to see if the location to be entered is an existing
Nu command, if it is it will let you inspect the command under `help`.

This provides baseline needed so we can iterate on it.
2019-08-31 19:06:11 -05:00
Jonathan Turner
f730296e45 WIP supporting from/to automatically 2019-08-29 15:53:45 +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
721a7b159d switch from reqwest to surf 2019-08-25 07:36:19 +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
e012e04da0 Disallow fileops on values 2019-08-22 05:03:59 +12: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
dd18122a24 WIP 2019-08-15 17:02:02 +12:00
Jonathan Turner
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
Andrés N. Robalino
ba6d62ea0c mkdir creates intermediary directories as required (the default). --create-all/--deep flag removed. 2019-08-07 14:38:00 -05:00
Andrés N. Robalino
50393bdf42 Make more visible the strategies for figuring out where to copy files. 2019-08-07 13:42:52 -05:00
Andrés N. Robalino
e0bacaaf37 clean up. more cp. mkdir. more test coverage. fixes.
- Introduced mkdir.
- Minor more labelled error improvements.
- Fix to avoid leaking child zombies.
- cp improvements.
- Introduced mkdir.
2019-08-07 13:28:46 -05:00
Andrés N. Robalino
c8b5329c5c mkdir. 2019-08-07 13:24:20 -05:00