Commit Graph

116 Commits

Author SHA1 Message Date
Michael Angerman
d4b6b4b09a
update all cargo crates to edition 2021 (#781) 2022-01-21 00:13:45 +11:00
Jakub Žádník
3b4baa31b6
Fix ls relative path & command argument path expansion (#757)
* Switch to short-names when the path is a relative_path (a dir) and exit with an error if the path does not exist

* Remove debugging print line

* Show relative filenames... It does not work yet for ls ../

* Try something else to fix relative paths... it works, but the ../ code part is not very pretty

* Add canonicalize check and remove code clones

* Fix the canonicalize_with issue pointed out by kubouch. Not sure the prefix_str is what kubouch suggested

* Fix the canonicalize_with issue pointed out by kubouch. Not sure the prefix_str is what kubouch suggested

* Add single-dot expansion to nu-path

* Move value path expansion from parser to eval

Fixes #745

* Remove single dot expansion from parser

It is not necessary since it will get expanded anyway in the eval.

* Fix ls to display globs with relative paths

* Use pathdiff crate to get relative paths for ls

Co-authored-by: Stefan Stanciulescu <contact@stefanstanciulescu.com>
2022-01-17 00:55:56 +11:00
JT
82d90f4930
Add support for var/string interp for external names (#729) 2022-01-13 19:17:45 +11:00
JT
186da4d725
Fixing captures (#723)
* WIP fixing captures

* small fix

* WIP

* Rewrite to proof-of-concept better parse_def

* Add missing file

* Finish capture refactor

* Fix tests

* Add more tests
2022-01-12 15:06:56 +11:00
JT
3478f35330
Default the values of named params (#695) 2022-01-07 07:32:47 +11:00
JT
41dbc641cc
Some cleanups for cd/PWD (#667)
* Some cleanups for cd/PWD

* Some cleanups for cd/PWD
2022-01-05 11:26:01 +11:00
Jakub Žádník
74dcd91cc3
Use only $nu.env.PWD for getting the current directory (#587)
* Use only $nu.env.PWD for getting current directory

Because setting and reading to/from std::env changes the global state
shich is problematic if we call `cd` from multiple threads (e.g., in a
`par-each` block).

With this change, when engine-q starts, it will either inherit existing
PWD env var, or create a new one from `std::env::current_dir()`.
Otherwise, everything that needs the current directory will get it from
`$nu.env.PWD`. Each spawned external command will get its current
directory per-process which should be thread-safe.

One thing left to do is to patch nu-path for this as well since it uses
`std::env::current_dir()` in its expansions.

* Rename nu-path functions

*_with is not *_relative which should be more descriptive and frees
"with" for use in a followup commit.

* Clone stack every each iter; Fix some commands

Cloning the stack each iteration of `each` makes sure we're not reusing
PWD between iterations.

Some fixes in commands to make them use the new PWD.

* Post-rebase cleanup, fmt, clippy

* Change back _relative to _with in nu-path funcs

Didn't use the idea I had for the new "_with".

* Remove leftover current_dir from rebase

* Add cwd sync at merge_delta()

This makes sure the parser and completer always have up-to-date cwd.

* Always pass absolute path to glob in ls

* Do not allow PWD a relative path; Allow recovery

Makes it possible to recover PWD by proceeding with the REPL cycle.

* Clone stack in each also for byte/string stream

* (WIP) Start moving env variables to engine state

* (WIP) Move env vars to engine state (ugly)

Quick and dirty code.

* (WIP) Remove unused mut and args; Fmt

* (WIP) Fix dataframe tests

* (WIP) Fix missing args after rebase

* (WIP) Clone only env vars, not the whole stack

* (WIP) Add env var clone to `for` loop as well

* Minor edits

* Refactor merge_delta() to include stack merging.

Less error-prone than doing it manually.

* Clone env for each `update` command iteration

* Mark env var hidden only when found in eng. state

* Fix clippt warnings

* Add TODO about env var reading

* Do not clone empty environment in loops

* Remove extra cwd collection

* Split current_dir() into str and path; Fix autocd

* Make completions respect PWD env var
2022-01-05 09:30:34 +11:00
JT
8f6843c600
Move $nu.env to $env (#665)
* Move env from nu builtin to its own

* update samples/tests
2022-01-05 08:34:42 +11:00
JT
b6fcd46075
Some error improvements (#659) 2022-01-04 10:14:33 +11:00
JT
354d51a3a6
Fix perf regression with stmts (#650) 2022-01-03 07:18:48 +11:00
Michael Angerman
f734995170
move get_columns from the table_viewer to a central location (#628)
* get_columns is working in the columns command

* the new location of the get_columns method is nu-protocol/src/column.rs

* reference the new location of the get_columns method

* move get_columns to nu-engine
2021-12-31 17:39:58 -08:00
JT
c8330523c8
Don't read config in a tight loop (#614) 2021-12-29 07:06:53 +11:00
JT
1dbf351425
Handle external redirects better (#598)
* Handle external redirects better

* fix warnings
2021-12-27 08:58:53 -06:00
JT
e62e0fb679
Flush stmts (#584)
* Flush the stmt via table to the screen

* Fix test
2021-12-27 07:21:24 +11:00
JT
ca6baf7a46
Add single tick string interpolation (#581)
* Add single tick string interpolation

* give string interpolation its own highlighting
2021-12-26 07:50:02 +11:00
JT
d603086d2f
Fix custom call scope leak, refactor tests (#580)
* Fix custom call scope leak, refactor tests

* Actually add tests
2021-12-26 06:39:42 +11:00
JT
3522bead97
Add string stream and binary stream, add text decoding (#570)
* WIP

* Add binary/string streams and text decoding

* Make string collection fallible

* Oops, forgot pretty hex

* Oops, forgot pretty hex

* clippy
2021-12-24 18:22:11 +11:00
Jakub Žádník
061c822c5d
Add environment variables doc page (#554)
* Fix typos

* Add environment variables doc page

* Remove Breaking Changes page
2021-12-23 06:44:14 +11:00
Jakub Žádník
8ba3e3570c
Interpret lists as series of args for externals (#550)
* Interpret lists as series of args for externals

* Fix clippy warnings
2021-12-22 10:13:05 +02:00
Jakub Žádník
deeb1da359
Allow having only one env conversion (#548)
Allows setting only `from_string` or `to_string` in `env_conversions`
config. Previously, both were required.
2021-12-22 00:32:38 +02:00
JT
266fac910a
Signature improves, sorted completions (#545) 2021-12-22 07:50:18 +11:00
Fernando Herrera
3ad5d4af66
sort env vars (#544) 2021-12-22 07:27:19 +11:00
JT
caf73c36f2
Finish adding support for optional params (#530) 2021-12-20 17:58:09 +11:00
Fernando Herrera
e949658381
nothing variable (#527)
* nothing variable

* corrected comments

* added color to nothing like bool

* compare nothing with values

* comparison tests
2021-12-20 12:05:33 +11:00
JT
2883d6cd1e
Remove Span::unknown (#525) 2021-12-19 18:46:13 +11:00
Jakub Žádník
6a0f404558
Treating environment variables as Values (#497)
* Proof of concept treating env vars as Values

* Refactor env var collection and method name

* Remove unnecessary pub

* Move env translations into a new file

* Fix LS_COLORS to support any Value

* Fix spans during env var translation

* Add span to env var in cd

* Improve error diagnostics

* Fix non-string env vars failing string conversion

* Make PROMPT_COMMAND a Block instead of String

* Record host env vars to a fake file

This will give spans to env vars that would otherwise be without one.
Makes errors less confusing.

* Add 'env' command to list env vars

It will list also their values translated to strings

* Sort env command by name; Add env var type

* Remove obsolete test
2021-12-17 12:04:54 +11:00
JT
2013e9300a
Make config default if broken (#482)
* Make config default if broken

* Make config default if broken
2021-12-13 14:16:51 +11:00
Darren Schroeder
9d7685e565
add temp-path to $nu (#471) 2021-12-11 14:00:29 -06:00
Darren Schroeder
c2aa6c708d
add cwd to $nu (#469)
* add `cwd` to `$nu`

* oops
2021-12-11 13:38:36 -06:00
Darren Schroeder
626b1b99cd
add keybinding-path to $nu (#470) 2021-12-11 13:29:56 -06:00
Darren Schroeder
4103abc685
add home-path to $nu (#468) 2021-12-11 13:12:30 -06:00
Fernando Herrera
865906e450
Dataframe commands name (#457)
* corrected missing shellerror type

* batch dataframe commands

* removed option to find declaration with input

* ordered dataframe folders

* dataframe command name
2021-12-09 18:17:11 -06:00
Fernando Herrera
1fd26727c5
Batch of dataframe commands (#442)
* corrected missing shellerror type

* batch dataframe commands

* removed option to find declaration with input

* ordered dataframe folders
2021-12-06 17:09:49 +13:00
Jakub Žádník
71a8eb6f8e
Add signature to $scope.commands (#434)
* Add signature to $scope.commands

* Change signature command column name
2021-12-04 22:01:51 +02:00
Jakub Žádník
405a4e58c7
Fix 'help commands'; Add 'is_custom' column (#420)
* Fix fetching commands; Add is_custom column

* Remove old comment
2021-12-03 20:45:29 +02:00
Fernando Herrera
f3c8d35eb7
Plugin repeated (#417)
* not repeated decl in file and help

* implemented heashmap for repeated

* sorted scope commands
2021-12-03 14:29:55 +00:00
Fernando Herrera
99de2b1d77
plugin path for $nu (#398) 2021-12-02 06:35:32 +00:00
Fernando Herrera
56307553ae
Plugin with evaluated call (#393)
* plugin trait

* impl of trait

* record and absolute path

* plugin example crate

* clippy error

* correcting cargo

* evaluated call for plugin
2021-12-02 05:42:56 +00:00
Jakub Žádník
c17e1473db
Hiding of environment variables (#362)
* Remember environment variables from previous scope

* Re-introduce env var hiding

Right now, hiding decls is broken

* Re-introduce hidden field of import patterns

All tests pass now.

* Remove/Address tests TODOs

* Fix test typo; Report hiding error

* Add a few more tests

* Fix wrong expected test result
2021-11-30 19:14:05 +13:00
Fernando Herrera
c8b16c14d5
Option to replace command same name (#374)
* option to replace command same name

* moved order of custom value declarations

* arranged dataframe folders and objects

* sort help commands by name

* added dtypes function for debugging

* corrected name for dataframe commands

* command names using function
2021-11-28 19:35:02 +00:00
JT
f7f8b0dbff
A few help cleanups (#372) 2021-11-28 07:16:20 +13:00
JT
f052b3313d
Move row condition to block (#368) 2021-11-26 16:49:03 +13:00
Fernando Herrera
76019f434e
Dataframe feature (#361)
* custom value trait

* functions for custom value trait

* custom trait behind flag

* open dataframe command

* command to-df for basic types

* follow path for dataframe

* dataframe operations

* dataframe not default feature

* custom as default feature

* corrected examples in command
2021-11-23 08:14:40 +00:00
Fernando Herrera
88988dc9f4
Plugins signature load (#349)
* saving signatures to file

* loading plugin signature from file

* is_plugin column for help command
2021-11-19 15:51:42 +13:00
Jakub Žádník
f8f437b060
Separate Overlay into its own thing (#344)
It's no longer attached to a Block. Makes access to overlays more
streamlined by removing this one indirection. Also makes it easier to
create standalone overlays without a block which might come in handy.
2021-11-17 17:23:55 +13:00
Fernando Herrera
b35914bd17
Category option for signature (#343)
* category option for signature

* category option for signature

* column description for $scope
2021-11-17 17:22:37 +13:00
Jakub Žádník
5459d30a24
Add environment variable support for modules (#331)
* Add 'expor env' dummy command

* (WIP) Abstract away module exportables as Overlay

* Switch to Overlays for use/hide

Works for decls only right now.

* Fix passing import patterns of hide to eval

* Simplify use/hide of decls

* Add ImportPattern as Expr; Add use env eval

Still no parsing of "export env" so I can't test it yet.

* Refactor export parsing; Add InternalError

* Add env var export and activation; Misc changes

Now it is possible to `use` env var that was exported from a module.

This commit also adds some new errors and other small changes.

* Add env var hiding

* Fix eval not recognizing hidden decls

Without this change, calling `hide foo`, the evaluator does not know
whether a custom command named "foo" was hidden during parsing,
therefore, it is not possible to reliably throw an error about the "foo"
name not found.

* Add use/hide/export env var tests; Cleanup; Notes

* Ignore hide env related tests for now

* Fix main branch merge mess

* Fixed multi-word export def

* Fix hiding tests on Windows

* Remove env var hiding for now
2021-11-16 12:16:06 +13:00
JT
0f107b2830
Add a config variable with engine support (#332)
* Add a config variable with engine support

* Add a config variable with engine support

* Oops, cleanup
2021-11-15 08:25:57 +13:00
JT
14a2918bba
Fix some nightly clippy warnings (#329) 2021-11-13 13:42:13 +13:00
JT
568e566adf
Add record literal syntax (#326) 2021-11-11 12:14:00 +13:00