Commit Graph

161 Commits

Author SHA1 Message Date
Dirkjan Ochtman
8523ce3d01 Get rid of feature(crate_visibility_modifier) (see #362) 2019-09-01 21:56:17 +02: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
Yehuda Katz
138b5af82b Basic support for decimal numbers
This commit is more substantial than it looks: there was basically no
real support for decimals before, and that impacted values all the way
through.

I also made Size contain a decimal instead of an integer (`1.6kb` is a
reasonable thing to type), which impacted a bunch of code.

The biggest impact of this commit is that it creates many more possible
ways for valid nu types to fail to serialize as toml, json, etc. which
typically can't support the full range of Decimal (or Bigint, which I
also think we should support). This commit makes to-toml fallible, and a
similar effort is necessary for the rest of the serializations.

We also need to figure out how to clearly communicate to users what has
happened, but failing to serialize to toml seems clearly superior to me
than weird errors in basic math operations.
2019-08-30 21:05:32 -07:00
Jonathan Turner
fa2c6ec227 Merge master 2019-08-31 10:13:09 +12:00
Taiki Endo
58a32490c5 Remove usage of in_band_lifetimes feature 2019-08-30 01:32:31 +09:00
est31
c87fa14fc8 Replace crate visibility identifier with pub(crate)
Result of running:

find src -name *.rs -exec sed -i 's/crate /pub(crate) /g' {} \;
2019-08-29 13:09:09 +02:00
Jonathan Turner
f730296e45 WIP supporting from/to automatically 2019-08-29 15:53:45 +12:00
Jonathan Turner
e0a13de943 Remove bind_by_move nightly feature 2019-08-29 14:44:08 +12:00
Yehuda Katz
dfe452bbc4 Remove unwraps from the parser
I intend to add regression tests for these cases to the parser as a
follow-up PR.

Fixes #490
Fixes #494
2019-08-27 14:20:18 -07: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
439700b87c Fix a few issues with textview and the parser 2019-08-25 19:15:56 +12:00
est31
8af4713237 Replace type_name intrinsic by stable type_name 2019-08-24 17:52:36 +02:00
Jonathan Turner
e3e4e30fb3 Lots of fixes ahead of release 2019-08-21 18:39:57 +12:00
Odin Dutton
b5b8e4c8b0 Fix warnings 2019-08-19 19:59:41 +10:00
Yehuda Katz
5bfb96447a Reduce unwraps
Remove a number of unwraps. In some cases, a `?` just worked as is. I also made it possible to use `?` to go from Result<OutputStream, ShellError> to OutputStream. Finally, started updating PerItemCommand to be able to use the signature deserialization logic, which substantially reduces unwraps.

This is still in-progress work, but tests pass and it should be clear to merge and keep iterating on master.
2019-08-16 20:53:39 -07:00
Yehuda Katz
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
Jonathan Turner
efd9631a90 All tests pass 2019-08-15 17:46:19 +12: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
Yehuda Katz
14a52bc282 WIP - more streamlining 2019-08-06 09:26:33 -07:00
Jonathan Turner
99671b8ffc Move more parts to tags and away from spans 2019-08-05 20:54:29 +12:00
Yehuda Katz
586aa6bae1 WIP - types check 2019-08-02 19:17:28 -07:00
Yehuda Katz
fc173c46d8 Restructuring 2019-08-02 12:15:07 -07:00
Jonathan Turner
a966e88424 Add question mark parsing 2019-08-02 15:15:04 +12:00
Jonathan Turner
8de50ae565 Allow wildcard globs to be used in a bare word 2019-08-02 12:03:28 +12:00
Jonathan Turner
462f783fac initial change to Tagged<Value> 2019-08-01 13:58:42 +12:00
Jonathan Turner
a09361698e Update plugin protocol for begin, and create new sys plugin 2019-07-27 19:45:00 +12:00
Yehuda Katz
73deeb69db Clean up lint errors 2019-07-23 21:10:48 -07:00
Yehuda Katz
5a8e041a48 Tests pass! 2019-07-23 15:22:11 -07:00
Jonathan Turner
d5d4da0bf8 Add first step of uuid generation and bookkeeping 2019-07-20 07:48:14 +12:00
Jonathan Turner
3b682046b7 new inc takes a path 2019-07-18 13:32:19 +12:00
Jonathan Turner
2ed46046bd Cleanup for upcoming release 2019-07-17 07:10:25 +12:00
Jonathan Turner
c7abb31b7c Fix inc plugin 2019-07-16 19:25:48 +12:00
Jonathan Turner
3ebb6ba991 Fix plugin's commandconfig 2019-07-16 19:08:35 +12:00
Jonathan Turner
60f4436849
Merge pull request #181 from nushell/string-arg
Make signatures a little more general
2019-07-16 09:40:36 +12:00
Yehuda Katz
ded3462e82 Make signatures a little more general 2019-07-15 14:16:27 -07:00
Jonathan Turner
59e3ca69f3
Merge pull request #177 from jonathandturner/fix_numeric_filenames
Check for barewords that start with a number
2019-07-16 06:04:00 +12:00
Jonathan Turner
bb13c2e234 Check for barewords that start with a number 2019-07-16 05:48:06 +12:00
Andrés N. Robalino
520ab55756 K raw unit is a kilobyte. 2019-07-14 22:47:01 -05:00
Andrés N. Robalino
7e78bb4af5 Informs passing flags is unimplemented instead of quitting. 2019-07-13 22:39:41 -05:00
Jonathan Turner
7e555a0ef2 "Add plugin arg errors. Bring remaining errors to parity" 2019-07-14 04:59:59 +12:00
Yehuda Katz
6bf55c0f1e Remove more dead code and clean up JSON 2019-07-12 19:20:26 -07:00
Yehuda Katz
7c2a1c619e Tests pass 2019-07-12 19:20:26 -07:00
Yehuda Katz
70f9e355fd WIP 2019-07-12 19:20:26 -07:00
Yehuda Katz
2da12aed56 Tests pass 2019-07-12 19:20:26 -07:00
Yehuda Katz
7b68739b52 WIP 2019-07-12 19:20:26 -07:00
Yehuda Katz
34033afce4 WIP improve error infrastructure
Also simplify commands and reduce papercuts
2019-07-12 19:20:26 -07:00
Jonathan Turner
75ddfe9f5a Add filter and sink plugins 2019-07-02 19:56:20 +12:00
Yehuda Katz
711ed05b43 Produce ArgumentError for signature mismatch
ArgumentError also automatically produces diagnostics
2019-06-29 23:14:40 -07:00
Yehuda Katz
5cac3d1135 Fix lints 2019-06-29 09:32:58 -07:00
Yehuda Katz
3379c23a49 Support evaluating most expressions
Blocks, paths, and others

Plus a bunch of other infra improvements
2019-06-29 01:55:42 -07:00
Jonathan Turner
d5704808d4 First working plugin 2019-06-27 16:56:48 +12:00
Jonathan Turner
8bf7ea1c6c Add at 2019-06-26 18:33:26 +12:00
Jonathan Turner
c969c2c362 Clean up old parser code 2019-06-25 16:33:12 +12:00
Jonathan Turner
160074346f Fix units and add test 2019-06-24 19:59:23 +12:00
Yehuda Katz
7957fc502f Fix a bunch of bugs 2019-06-23 18:55:31 -06:00
Yehuda Katz
bed5ba52d3 Fixed trailing issues 2019-06-23 15:36:01 -04:00
Yehuda Katz
cbab97174e Fix painting 2019-06-23 13:35:43 -04:00
Yehuda Katz
d0860837d2 Merge branch 'nom2' into nom4 2019-06-22 18:20:13 -04:00
Yehuda Katz
4036bf1ffd &str -> Text 2019-06-22 16:46:16 -04:00
Jonathan Turner
dc081151bc add back some shell coloring 2019-06-23 07:47:29 +12:00
Jonathan Turner
37c4fb92f8 Fix raw as a variable 2019-06-23 06:32:58 +12:00
Jonathan Turner
72a61f557b Remove debug println 2019-06-23 04:59:37 +12:00
Jonathan Turner
0046305ea1 Fix conflicts 2019-06-23 04:31:51 +12:00
Yehuda Katz
3b35dcb619 Finish nom upgrade 2019-06-22 10:08:53 -04:00
Jonathan Turner
1c0096b2fb WIP 2019-06-22 15:49:49 +12:00
Jonathan Turner
9ae9beb94a WIP 2019-06-22 15:43:37 +12:00
Jonathan Turner
baeb192f12 Merge master 2019-06-22 13:38:17 +12:00
Yehuda Katz
e981129f1f Things work 2019-06-21 21:36:57 -04:00
Jonathan Turner
a764a64161 Move back onto main subprocess 2019-06-18 14:04:34 +12:00
Yehuda Katz
6e222eec2b More delimiters 2019-06-14 20:16:13 -07:00
Yehuda Katz
640484063b More tests 2019-06-14 20:16:13 -07:00
Yehuda Katz
4f3a5f0300 Paths 2019-06-14 20:16:13 -07:00
Yehuda Katz
c5c14e2d89 Add a bunch more tokens and delimited () 2019-06-14 20:16:13 -07:00
Yehuda Katz
4291e31dc7 Start rebuilding lite parser using nom 2019-06-14 20:16:13 -07:00
Yehuda Katz
2b876da56f Some function stuff
It's not done, but honestly it's getting too tedious. I will need to
rethink how I'm doing it.
2019-06-10 13:11:55 -07:00
Jonathan Turner
62fac11e07 Cleanup and bump rustyline 2019-06-10 05:52:56 +12:00
Jonathan Turner
e94d1d2758 Add pretty errors to commands 2019-06-08 10:35:07 +12:00
Jonathan Turner
f31c08e941
Merge pull request #87 from wycats/better-parser
Span all the things
2019-06-06 20:00:37 +12:00
Yehuda Katz
324f7915be Span all the things
Also set up builder infra for more consistent AST creation.
2019-06-05 23:34:59 -07:00
Jonathan Turner
8cb77034f3 Fix quoted strings in linux 2019-06-05 14:27:53 +12:00
Yehuda Katz
f3bb4a03c2 Improve parser 2019-06-04 14:42:31 -07:00
Yehuda Katz
a8574abbf2 Improve errors 2019-06-02 22:11:21 -07:00
Yehuda Katz
b9159f033b Parsing tests 2019-06-02 09:28:40 -07:00
Yehuda Katz
5d4097073b Add --loglevel and --develop
--loglevel sets the log level for all of nu
--develop takes a list of modules and turns on trace mode for them
2019-06-01 10:00:42 -07:00
Jonathan Turner
5d901a11e1
Add from_toml (#54) 2019-06-01 19:05:57 +12:00
Yehuda Katz
69effbc9e7 Improve signature infrastructure
The `config` command uses different kinds of named arguments, which
illustrates how it works.
2019-05-31 22:54:15 -07:00
Jonathan Turner
72c4bb20b3 Fix bare dot paths and add dot paths to select 2019-06-01 07:15:29 +12:00
Jonathan Turner
f38726d2aa Add back in number w/ units parsing 2019-06-01 05:21:03 +12:00
Yehuda Katz
b319381d84 Improve highlighting 2019-05-31 09:33:46 -07:00
Yehuda Katz
9e9c0b9811 Fix bare word .
Addresses `git add .`
2019-05-30 22:45:57 -07:00
Yehuda Katz
9a639fd27b Syntax highlighting 2019-05-30 17:53:54 -07:00
Yehuda Katz
c523ae0f48 More fixes for external args 2019-05-29 22:33:47 -07:00
Yehuda Katz
b7d15c2afd Better errors and more fleshed out semantics 2019-05-29 21:19:46 -07:00
Yehuda Katz
e4013a008c Custom lexer 2019-05-29 08:26:45 -07:00
Jonathan Turner
f44936ea5a Some fixes for the new evaluator 2019-05-28 19:19:16 +12:00
Yehuda Katz
d5255f6dbf
Evaluator MVP (#39)
Evaluator, MVP
2019-05-27 23:45:18 -07:00
Jonathan Turner
10702cd27f Add size units to parsing 2019-05-28 17:05:14 +12:00
Jonathan Turner
b34676441b Add json support 2019-05-28 14:01:37 +12:00
Yehuda Katz
b74daa2e60 A real parser (lalrpop) 2019-05-26 00:17:35 -07:00