* [wasi] Update time & instant crates
In https://github.com/nushell/nushell/pull/2643 instant was updated by adding it as a hard dependency in Cargo.toml, but it's better to avoid it and only update in Cargo.lock via `cargo update -p ...`.
Additionally, updated `time` crate so that now some basic commands like `ls` work too, although formatting is pretty bad.
* Update default terminal width to 80
If termsize can't return anything, use 80 chars (e.g. on WASI).
* Add system, user and idle times to benchmark command
* Feature-gate dependency on heim in benchmark
* Reorder let bindings in benchmark
* Fully feature-gate rich-benchmark and print 0sec on zero duration
* remove unused dependencies
* moved umask to cfg(unix)
* changed Inflector to inflector, hoping it fixes the issue.
* roll back Inflector
* removed commented out deps now that everything looks good.
* make sort-by fail gracefully if mismatched types are compared
* Added a test to check if sorted-by with invalid types exists gracefully
* Linter changes
* removed redundant pattern matching
* Changed the error message
* Added a comma after every argument
* Changed the test to accomodate the new err messages
* Err message for sort-by invalid types now shows the mismatched types
* Lints problems
* Changed unwrap to expect
* Add commit to version command
* Replace unwrap with expect.
* Only have commit hash if git doesn't error
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
* Updated version hashing and bumped nu-cli to 0.18.1
* made code pertyer
* Update version.rs
* Update version.rs
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
* add 228 json html themes
removed old assets, added new zipped asset
added --list to get a list of the theme names
reworked some older theme code
added rust-embed and zip crate
removed the dark tests
* fmt
* Updated, removed excess comments
Changed usage a bit
Updated the error handling
Added some helper items in --list
* removed rustyline config duplication
set other rustyline defaults if line_editor section doesn't exist
updated keyseq_timeout to -1 if emacs mode is chosen
* change checking rustyline config to if lets
* removed some unneccessary code
Refactored out most of internal work for summarizing data opening
the door for generating charts from it. A model is introduced
to hold information needed for a summary, Histogram command is
an example of a partial usage. This is the beginning.
Removed implicit arithmetic traits on Value and Primitive to avoid
mixed types panics. The std operations traits can't fail and we
can't guarantee that. We can handle gracefully now since compute_values
was introduced after the parser changes four months ago. The handling
logic should be taken care of either explicitly or in compute_values.
The zero identity trait was also removed (and implementing this forced
us to also implement Add, Mult, etc)
Also: the `math` operations now remove in the output if a given column is not computable:
```
> ls | math sum
──────┬──────────
size │ 150.9 KB
──────┴──────────
```
* Working towards a PoC for wasm
* Move bson and sqlite to plugins
* proof of concept now working
* tests are green
* Add CI test for --no-default-features
* Fix some tests
* Fix clippy and windows build
* More fixes
* Fix the windows build
* Fix the windows test
* add human, precision commands
* add 'str from' subcommand (converted from human/precision commands)
move human tests to str from
* add default locale, platform-specific SystemLocale use
* fix platform specific num-format dependency, remove invalid test
* change 'str from' localization to static num_format::Locale::en
* minor cleanup, nudge ci
* re-attempt ci
* 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
* Update calculate to return a table when Value is a table
* impl mode subcommand for math
* add tests for math mode subcommand
* add table/row tests for math mode subcommand
* fix formatting
* WIP - changes to support bat config
* added bat configuration
* removed debug info
* clippy fix
* changed [bat] to [textview]
Co-authored-by: Darren Schroeder <fdncred@hotmail.com>
* WIP - Modified textview to use bat crate
* use input_from_bytes_with_name instead of input_file
* removed old paging
added prettyprint on else blocks
duplicated too much code
hard coded defaults
Co-authored-by: Darren Schroeder <fdncred@hotmail.com>
* WIP - not compiling
* compiling but panicing
* still broken
* nearly working
* reverted deserializer_string changes
updated enter.rs and open.rs to use Option<Tagged<String>>
Accepted Clippy suggestions
Accepted fmt suggestions
Left original code from open.rs
We may want to use some of it and only fallback to encoding.
* Don't exit when there is an unknown encoding.
* When encoding is unknown default to utf-8.
* only do encoding if the user says to it
* merged some conflicts on open
* made error messages consistent
* Updated unwrap with expect
* updated open test to pass with more descriptive err
updated enter test to not fail
* change _location to location
* changed _visitor to visitor
* Added a more verbose usage statement for encoding
Linked to docs.rs/encoding_rs for details
Co-authored-by: Darren Schroeder <fdncred@hotmail.com>
* Possible implementation of globbing for start command
* Whoops forgot to remove Error used for debugging
* Use string lossy
* Run clippy
* Pin glob
* Better error messages
* Remove unneeded comment
* added helper to convert data to strings
added ability to auto-rotate single row output
if row will be greater than terminal width
* Added pivot_to_fit config value
* Added ColumnPath to convert_to_string helper
* Figured out I had to run `cargo fmt --all -- --check`
Co-authored-by: Darren Schroeder <fdncred@hotmail.com>
* mvp for start command
* modified the signature of the start command
* parse filenames
* working model for macos is done
* refactored to read from pipes
* start command works well on macos; manual testing reveals need of --args flag support
* implemented start error; color printing of warning and errors
* ran clippy and fixed warnings
* fix a clippy lint that was caught in pipeline
* fix dead code clippy lint for windows
* add cfg annotation to import
* Changes to allow plugins to be loaded in a multi-threaded manner in order to decrease startup time.
* Ran rust fmt and clippy to find and fix first pass errors.
Updated launch.jason to make debugging easier in vscode.
Also added tasks.json so tasks like clippy can be ran easily.
* ran fmt again
* Delete launch.json
Remove IDE settings file
* Remove IDE settings file
* Ignore vscode IDE settings
* Cloned the context instead of Arc/Mutexing it.
Co-authored-by: Darren Schroeder <fdncred@hotmail.com>
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
* fix: absolutize path against its parent if it was a symlink.
On Linux this happens because Rust calls readlink but doesn't canonicalize the resultant path.
* feat: playground function to create symlinks
* fix: use playground dirs
* feat: test for #1631, shift tests names
* Creation of FilesystemShell with custom location may fail
* Replace ichwh with which
* Creation of FilesystemShell with custom location may fail
* Replace ichwh with which
* fix: add ichwh again since it cannot be completely replaced
* fix: replace one more use of which
* Making Commands match what UntaggedValue needs
* WIP
* WIP
* WIP
* Moved to expressions for conditions
* Add 'each' command to use command blocks
* More cleanup
* Add test for 'each'
* Instead use an expression block
Previously, if the user didn't have the appropriate permissions to execute the
binary/script, they would see "command not found", which is confusing.
This commit eliminates the `which` crate in favour of `ichwh`, which deals
better with permissions by not dealing with them at all! This is closer to the
behaviour of `which` in many shells. Permission checks are then left up to the
caller to deal with.
* WIP: move to bytes codec
* Progress on adding collect helpers
* Progress on adding collect helpers
* Add in line splitting back to lines
* Lines outputting line primitives
* Close to ready?
* Finish fixing lines
* clippy fixes
* fmt fixes
* removed unused code
* Cleanup a few bits
* Cleanup a few bits
* Cleanup a few more bits
* Fix failing test with corrected test case
This improves incremental build time when working on what was previously
the root package. For example, previously all plugins would be rebuilt
with a change to `src/commands/classified/external.rs`, but now only
`nu-cli` will have to be rebuilt (and anything that depends on it).
* Add block size to du
* Change blocks to physical size
* Use path instead of strings for file/directory names
* Why don't I just use paths instead of strings anyway?
* shorten physical size and apparent size to physical and apparent resp.
* Refactor pipeline ahead of block changes. Add '-c' commandline option
* Update pipelining an error value
* Fmt
* Clippy
* Add stdin redirect for -c flag
* Add stdin redirect for -c flag
* Upgrade futures, async-stream, and futures_codec
These were the last three dependencies on futures-preview. `nu` itself
is now fully dependent on `futures@0.3`, as opposed to `futures-preview`
alpha.
Because the update to `futures` from `0.3.0-alpha.19` to `0.3.0` removed
the `Stream` implementation of `VecDeque` ([changelog][changelog]), most
commands that convert a `VecDeque` to an `OutputStream` broke and had to
be fixed.
The current solution is to now convert `VecDeque`s to a `Stream` via
`futures::stream::iter`. However, it may be useful for `futures` to
create an `IntoStream` trait, implemented on the `std::collections` (or
really any `IntoIterator`). If something like this happends, it may be
worthwhile to update the trait implementations on `OutputStream` and
refactor these commands again.
While upgrading `futures_codec`, we remove a custom implementation of
`LinesCodec`, as one has been added to the library. There's also a small
refactor to make the stream output more idiomatic.
[changelog]: https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md#030---2019-11-5
* Upgrade sys & ps plugin dependencies
They were previously dependent on `futures-preview`, and `nu_plugin_ps`
was dependent on an old version of `futures-timer`.
* Remove dependency on futures-timer from nu
* Update Cargo.lock
* Fix formatting
* Revert fmt regressions
CI is still on 1.40.0, but the latest rustfmt v1.41.0 has changes to the
`val @ pattern` syntax, causing the linting job to fail.
* Fix clippy warnings
Restructure and streamline token expansion
The purpose of this commit is to streamline the token expansion code, by
removing aspects of the code that are no longer relevant, removing
pointless duplication, and eliminating the need to pass the same
arguments to `expand_syntax`.
The first big-picture change in this commit is that instead of a handful
of `expand_` functions, which take a TokensIterator and ExpandContext, a
smaller number of methods on the `TokensIterator` do the same job.
The second big-picture change in this commit is fully eliminating the
coloring traits, making coloring a responsibility of the base expansion
implementations. This also means that the coloring tracer is merged into
the expansion tracer, so you can follow a single expansion and see how
the expansion process produced colored tokens.
One side effect of this change is that the expander itself is marginally
more error-correcting. The error correction works by switching from
structured expansion to `BackoffColoringMode` when an unexpected token
is found, which guarantees that all spans of the source are colored, but
may not be the most optimal error recovery strategy.
That said, because `BackoffColoringMode` only extends as far as a
closing delimiter (`)`, `]`, `}`) or pipe (`|`), it does result in
fairly granular correction strategy.
The current code still produces an `Err` (plus a complete list of
colored shapes) from the parsing process if any errors are encountered,
but this could easily be addressed now that the underlying expansion is
error-correcting.
This commit also colors any spans that are syntax errors in red, and
causes the parser to include some additional information about what
tokens were expected at any given point where an error was encountered,
so that completions and hinting could be more robust in the future.
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
This commit changes the way we shell out externals when using the `"$it"` argument. Also pipes per row to an external's stdin if no `"$it"` argument is present for external commands.
Further separation of logic (preparing the external's command arguments, getting the data for piping, emitting values, spawning processes) will give us a better idea for lower level details regarding external commands until we can find the right abstractions for making them more generic and unify within the pipeline calling logic of Nu internal's and external's.
* Detect built-in commands passed as args to `which`
This expands the built-in `which` command to detect nushell commands
that may have the same name as a binary in the path.
* Allow which to interpret multiple arguments
Previously, it would discard any argument besides the first. This allows
`which` to process multiple arguments. It also makes the output a stream
of rows.
* Use map to build the output
* Add boolean column for builtins
* Use macros for entry creation shortcuts
* Process command args and use async_stream
In order to use `ichwh`, I'll need to use async_stream. But in order to
avoid lifetime errors with that, I have to process the command args
before using them. I'll admit I don't fully understand what is going on
with the `args.process(...)` function, but it works.
* Use `ichwh` for path searching
This commit transitions from `which` to `ichwh`. The path search is now
done asynchronously.
* Enable the `--all` flag on `which`
* Make `which` respect external commands
Escaped commands passed to wich (e.g., `which "^ls"`), are now searched
before builtins.
* Fix clippy warnings
This commit resolves two warnings from clippy, in light of #1142.
* Update Cargo.lock to get new `ichwh` version
`ichwh@0.2.1` has support for local paths.
* Add documentation for command
* Manifests check. Ignore doctests for now.
* We continue with refactorings towards the separation of concerns between
crates. `nu_plugin_inc` and `nu_plugin_str` common test helpers usage
has been refactored into `nu-plugin` value test helpers.
Inc also uses the new API for integration tests.