Commit Graph

57 Commits

Author SHA1 Message Date
Jonathan Turner
95feb1ff16 Fix line completion for extended chars 2019-09-03 06:06:25 +12: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
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
570a0ac275 Fix path-related parts of value shell 2019-08-27 17:15:05 +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
Andrés N. Robalino
92ce31ac46 rmwrapped cd - ls 2019-08-22 23:51:43 -05:00
Jonathan Turner
03c29b9a6f Remove an unwrap 2019-08-23 04:44:31 +12:00
Jonathan Turner
399b411a9c
Merge pull request #332 from jonathandturner/fix_abs_ls
Fix absolute ls
2019-08-22 20:18:21 +12:00
Jonathan Turner
effbc56ec8 Fix absolute ls 2019-08-22 19:52:57 +12:00
Jonathan Turner
b9b462ffeb Remove dep import 2019-08-22 17:15:14 +12:00
Jonathan Turner
87930ba35a Fix tests 2019-08-22 16:23:57 +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
73e3402e2f Merge master 2019-08-22 05:09:23 +12:00
Jonathan Turner
e012e04da0 Disallow fileops on values 2019-08-22 05:03:59 +12:00
Jonathan Turner
953d28ef74 Fix push/pop for shell manager 2019-08-19 20:07:55 +12:00
Jonathan Turner
fef447a659 Fix shell-ring to rotate as expected 2019-08-19 19:29:27 +12: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
dd18122a24 WIP 2019-08-15 17:02:02 +12:00
Jonathan Turner
8f78995014 Improve enter and fix bugs 2019-08-11 08:18:14 +12:00
Jonathan Turner
60e7dfcf1b Add back command completions 2019-08-10 17:02:15 +12:00
Jonathan Turner
eeed31837f cleanup 2019-08-10 08:49:43 +12:00
Jonathan Turner
34759b7646 Add back in cd/ls and completions 2019-08-10 07:42:23 +12:00
Jonathan Turner
cabd5bf009 Fix sink plugins 2019-08-09 19:54:21 +12:00
Jonathan Turner
83030094e0 All tests pass 2019-08-09 17:36:43 +12:00
Jonathan Turner
aadacc2d36 Merge master 2019-08-09 16:51:21 +12:00
Jonathan Turner
e8ae46ddb5 Fix the canonicalize of set_path 2019-08-08 12:52:29 +12:00
Jonathan Turner
c231dd32cd
Multi shells (#254)
Add multi-shells
2019-08-08 05:49:11 +12:00
Jonathan Turner
462f783fac initial change to Tagged<Value> 2019-08-01 13:58:42 +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
Yehuda Katz
ded3462e82 Make signatures a little more general 2019-07-15 14:16:27 -07:00
Jonathan Turner
5261d5f43f Fix space and escaped paren completions 2019-07-15 17:40:27 +12:00
Jonathan Turner
c969c2c362 Clean up old parser code 2019-06-25 16:33:12 +12:00
Jonathan Turner
dea5ff17c3 Remove println 2019-06-24 16:13:01 +12:00
Jonathan Turner
dd4e59d627 Fix coloring of commands 2019-06-24 16:00:16 +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
Yehuda Katz
e981129f1f Things work 2019-06-21 21:36:57 -04:00
Jonathan Turner
62fac11e07 Cleanup and bump rustyline 2019-06-10 05:52:56 +12: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
Yehuda Katz
b319381d84 Improve highlighting 2019-05-31 09:33:46 -07:00
Yehuda Katz
9a639fd27b Syntax highlighting 2019-05-30 17:53:54 -07:00