nushell/crates/nu-cli/src/commands
Sam Hedin ee18f16378
Autoenv rewrite, security and scripting (#2083)
* Add args in .nurc file to environment

* Working dummy version

* Add add_nurc to sync_env command

* Parse .nurc file

* Delete env vars after leaving directory

* Removing vals not working, strangely

* Refactoring, add comment

* Debugging

* Debug by logging to file

* Add and remove env var behavior appears correct

However, it does not use existing code that well.

* Move work to cli.rs

* Parse config directories

* I am in a state of distress

* Rename .nurc to .nu

* Some notes for me

* Refactoring

* Removing vars works, but not done in a very nice fashion

* Refactor env_vars_to_delete

* Refactor env_vars_to_add()

* Move directory environment code to separate file

* Refactor from_config

* Restore env values

* Working?

* Working?

* Update comments and change var name

* Formatting

* Remove vars after leaving dir

* Remove notes I made

* Rename config function

* Clippy

* Cleanup and handle errors

* cargo fmt

* Better error messages, remove last (?) unwrap

* FORMAT PLZ

* Rename whitelisted_directories to allowed_directories

* Add comment to clarify how overwritten values are restored.

* Change list of allowed dirs to indexmap

* Rewrite starting

* rewrite everything

* Overwritten env values tracks an indexmap instead of vector

* Refactor restore function

* Untrack removed vars properly

* Performance concerns

* Performance concerns

* Error handling

* Clippy

* Add type aliases for String and OsString

* Deletion almost works

* Working?

* Error handling and refactoring

* nicer errors

* Add TODO file

* Move outside of loop

* Error handling

* Reworking adding of vars

* Reworking adding of vars

* Ready for testing

* Refactoring

* Restore overwritten vals code

* todo.org

* Remove overwritten values tracking, as it is not needed

* Cleanup, stop tracking overwritten values as nu takes care of it

* Init autoenv command

* Initialize autoenv and autoenv trust

* autoenv trust toml

* toml

* Use serde for autoenv

* Optional directory arg

* Add autoenv untrust command

* ... actually add autoenv untrust this time

* OsString and paths

* Revert "OsString and paths"

This reverts commit e6eedf8824.

* Fix path

* Fix path

* Autoenv trust and untrust

* Start using autoenv

* Check hashes

* Use trust functionality when setting vars

* Remove unused code

* Clippy

* Nicer errors for autoenv commands

* Non-working errors

* Update error description

* Satisfy fmt

* Errors

* Errors print, but not nicely

* Nicer errors

* fmt

* Delete accidentally added todo.org file

* Rename direnv to autoenv

* Use ShellError instead of Error

* Change tests to pass, danger zone?

* Clippy and errors

* Clippy... again

* Replace match with or_else

* Use sha2 crate for hashing

* parsing and error msg

* Refactoring

* Only apply vars once

* if parent dir

* Delete vars

* Rework exit code

* Adding works

* restore

* Fix possibility of infinite loop

* Refactoring

* Non-working

* Revert "Non-working"

This reverts commit e231b85570.

* Revert "Revert "Non-working""

This reverts commit 804092e46a.

* Autoenv trust works without restart

* Cargo fix

* Script vars

* Serde

* Serde errors

* Entry and exitscripts

* Clippy

* Support windows and handle errors

* Formatting

* Fix infinite loop on windows

* Debugging windows loop

* More windows infinite loop debugging

* Windows loop debugging #3

* windows loop #4

* Don't return err

* Cleanup unused code

* Infinite loop debug

* Loop debugging

* Check if infinite loop is vars_to_add

* env_vars_to_add does not terminate, skip loop as test

* Hypothesis: std::env::current_dir() is messing with something

* Hypothesis: std::env::current_dir() is messing with something

* plz

* make clippy happy

* debugging in env_vars_to_add

* Debbuging env_vars_to_add #2

* clippy

* clippy..

* Fool clippy

* Fix another infinite loop

* Binary search for error location x)

* Binary search #3

* fmt

* Binary search #4

* more searching...

* closing in... maybe

* PLZ

* Cleanup

* Restore commented out functionality

* Handle case when user gives the directory "."

* fmt

* Use fs::canonicalize for paths

* Create optional script section

* fmt

* Add exitscripts even if no entryscripts are defined

* All sections in .nu-env are now optional

* Re-read config file each directory change

* Hot reload after autoenv untrust, don't run exitscripts if untrusted

* Debugging

* Fix issue with recursive adding of vars

* Thank you for finding my issues Mr. Azure

* use std::env
2020-07-06 05:34:00 +12:00
..
classified Autoenv rewrite, security and scripting (#2083) 2020-07-06 05:34:00 +12:00
math Configurable built-in prompts (#2064) 2020-06-27 10:37:31 +12:00
parse Bring back parse as built-in. 2020-06-04 15:21:13 -05:00
random Add dice subcommand to random command (#2082) 2020-06-30 16:12:51 +12:00
split Add 'split chars' command (#2101) 2020-07-04 07:09:38 +12:00
str_ Add 'str length' command (#2102) 2020-07-04 08:17:44 +12:00
alias.rs Another batch of removing async_stream (#1970) 2020-06-12 20:34:41 +12:00
ansi.rs More ansi (#2067) 2020-06-27 10:29:09 -05:00
append.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
args.rs Move most of the root package into a subcrate. (#1445) 2020-03-04 13:58:20 -05:00
autoenv_trust.rs Autoenv rewrite, security and scripting (#2083) 2020-07-06 05:34:00 +12:00
autoenv_untrust.rs Autoenv rewrite, security and scripting (#2083) 2020-07-06 05:34:00 +12:00
autoenv.rs Autoenv rewrite, security and scripting (#2083) 2020-07-06 05:34:00 +12:00
autoview.rs Bubble errors even if pipeline isn't used (#2080) 2020-06-30 05:39:11 +12:00
build_string.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
cal.rs Cal improvements (#2074) 2020-06-29 05:16:10 +12:00
calc.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
cd.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
char_.rs added a few more command chars (#2086) 2020-07-01 17:34:11 -05:00
clear.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
clip.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
command.rs Bubble errors even if pipeline isn't used (#2080) 2020-06-30 05:39:11 +12:00
compact.rs Numbered each (#2100) 2020-07-03 20:43:55 +12:00
config.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
constants.rs Convert open/fetch to stream (#2028) 2020-07-04 07:53:20 +12:00
count.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
cp.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
date.rs added raw to date for string output (#2075) 2020-06-28 09:01:13 -05:00
debug.rs Batch of moving commands off async_stream (#1917) 2020-05-30 16:34:39 +12:00
default.rs Batch of moving commands off async_stream (#1917) 2020-05-30 16:34:39 +12:00
do_.rs WIP (#2077) 2020-06-29 09:06:05 +12:00
drop.rs Batch of moving commands off async_stream (#1917) 2020-05-30 16:34:39 +12:00
du.rs Batch of moving commands off async_stream (#1917) 2020-05-30 16:34:39 +12:00
each.rs Numbered each (#2100) 2020-07-03 20:43:55 +12:00
echo.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
enter.rs Convert open/fetch to stream (#2028) 2020-07-04 07:53:20 +12:00
evaluate_by.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
every.rs Add 'every' command to select (or skip) every nth row (#1992) 2020-06-17 07:58:41 +12:00
exit.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
first.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
format.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
from_bson.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_csv.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_delimited_data.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_eml.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
from_ics.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
from_ini.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_json.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
from_ods.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
from_sqlite.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_ssv.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
from_toml.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
from_tsv.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_url.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_vcf.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
from_xlsx.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
from_xml.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
from_yaml.rs issue1332 - Fix for yamls with unquoted double curly braces (#1988) 2020-06-17 07:12:04 +12:00
from.rs Another batch of removing async_stream (#1970) 2020-06-12 20:34:41 +12:00
get.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
group_by_date.rs Refactoring and more group-by flexibility. 2020-06-17 13:34:17 -05:00
group_by.rs Refactoring and more group-by flexibility. 2020-06-17 13:34:17 -05:00
headers.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
help.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
histogram.rs Refactoring and more group-by flexibility. 2020-06-17 13:34:17 -05:00
history.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
if_.rs If command and touchups (#2106) 2020-07-05 07:40:04 +12:00
insert.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
is_empty.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
keep_until.rs Another batch of removing async_stream (#1981) 2020-06-14 11:54:35 +12:00
keep_while.rs Another batch of removing async_stream (#1981) 2020-06-14 11:54:35 +12:00
keep.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
kill.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
last.rs Show entire table if number of rows requested for last is greater than table size (#2112) 2020-07-05 13:04:17 +12:00
lines.rs Fix buffering in lines command (#2111) 2020-07-05 12:20:58 +12:00
ls.rs Batch of moving commands off async_stream (#1916) 2020-05-30 11:36:04 +12:00
macros.rs Move most of the root package into a subcrate. (#1445) 2020-03-04 13:58:20 -05:00
map_max_by.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
merge.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
mkdir.rs Implement an option to show paths made of mkdir. (#1932) 2020-06-06 15:13:38 -04:00
mv.rs Removing async_stream! from some more commands (#1973) 2020-06-13 20:03:13 +12:00
next.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
nth.rs If command and touchups (#2106) 2020-07-05 07:40:04 +12:00
open.rs If command and touchups (#2106) 2020-07-05 07:40:04 +12:00
pivot.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
plugin.rs Last batch of removing async_stream (#1983) 2020-06-15 09:00:42 +12:00
prepend.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
prev.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
pwd.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
range.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
reduce_by.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
reject.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
rename.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
reverse.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
rm.rs Moving some commands off of async stream (#1934) 2020-06-04 20:42:23 +12:00
run_alias.rs WIP (#2077) 2020-06-29 09:06:05 +12:00
run_external.rs Autoenv rewrite, security and scripting (#2083) 2020-07-06 05:34:00 +12:00
save.rs Bubble errors even if pipeline isn't used (#2080) 2020-06-30 05:39:11 +12:00
select.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
shells.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
shuffle.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
size.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
skip_until.rs Fix regression. skip-until 'skips' until condition is met. 2020-06-17 14:08:09 -05:00
skip_while.rs Another batch of removing async_stream (#1981) 2020-06-14 11:54:35 +12:00
skip.rs Removing async_stream! from some commands (#1940) 2020-06-06 19:42:06 +12:00
sort_by.rs Sort primitives explictly. (#2016) 2020-06-19 23:34:36 -05:00
split_by.rs Refactoring and more split-by flexibility. 2020-06-17 13:34:17 -05:00
t_sort_by.rs Refactoring and more group-by flexibility. 2020-06-17 13:34:17 -05:00
table.rs Bump deps and touchup (#2066) 2020-06-27 19:54:31 +12:00
tags.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
to_bson.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_csv.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_delimited_data.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_html.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
to_json.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_md.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
to_sqlite.rs Remove async_stream! from some commands (#1951) 2020-06-08 16:48:10 +12:00
to_toml.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_tsv.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
to_url.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
to_yaml.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
to.rs Another batch of converting commands away from async_stream (#1974) 2020-06-13 20:43:21 +12:00
touch.rs Removing async_stream! from some more commands (#1973) 2020-06-13 20:03:13 +12:00
trim.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
uniq.rs Uniq: --count flag to count occurences (#2017) 2020-06-21 12:22:06 +12:00
update.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
version.rs Move run to be async (#1913) 2020-05-29 20:22:52 +12:00
what.rs Another batch of removing async_stream (#1971) 2020-06-13 11:40:23 +12:00
where_.rs Another batch of removing async_stream (#1978) 2020-06-14 07:13:36 +12:00
which_.rs Another batch of removing async_stream (#1972) 2020-06-13 16:03:39 +12:00
with_env.rs Another batch of removing async_stream (#1979) 2020-06-14 10:01:44 +12:00
wrap.rs Another batch of removing async_stream (#1971) 2020-06-13 11:40:23 +12:00