3.6 KiB
Contributing
Welcome to Nushell and thank you for considering contributing!
Review Process
First of all, before diving into the code, if you want to create a new feature, change something significantly, and especially if the change is user-facing, it is a good practice to first get an approval from the core team before starting to work on it. This saves both your and our time if we realize the change needs to go another direction before spending time on it. So, please, reach out and tell us what you want to do. This will significantly increase the chance of your PR being accepted.
The review process can be summarized as follows:
- You want to make some change to Nushell that is more involved than simple bug-fixing.
- Go to Discord or a GitHub issue and chat with some core team members and/or other contributors about it.
- After getting a green light from the core team, implement the feature, open a pull request (PR) and write a concise but comprehensive description of the change.
- If your PR includes any use-facing features (such as adding a flag to a command), clearly list them in the PR description.
- Then, core team members and other regular contributors will review the PR and suggest changes.
- When we all agree, the PR will be merged.
- If your PR includes any user-facing features, make sure the changes are also reflected in the documentation after the PR is merged.
- Congratulate yourself, you just improved Nushell! :-)
Developing
Setup
Nushell requires a recent Rust toolchain and some dependencies; refer to the Nu Book for up-to-date requirements. After installing dependencies, you should be able to clone+build Nu like any other Rust project:
git clone https://github.com/nushell/nushell
cd nushell
cargo build
Tests
It is a good practice to cover your changes with a test. Also, try to think about corner cases and various ways how your changes could break. Cover those in the tests as well.
Tests can be found in different places:
/tests
src/tests
- command examples
- crate-specific tests
The most comprehensive test suite we have is the nu-test-support
crate. For testing specific features, such as running Nushell in a REPL mode, we have so called "testbins". For simple tests, you can find run_test()
and fail_test()
functions.
Useful Commands
-
Build and run Nushell:
cargo run
-
Build and run with extra features. Currently extra features include dataframes and sqlite database support.
cargo run --features=extra
-
Run Clippy on Nushell:
cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
-
Run all tests:
cargo test --workspace --features=extra
-
Run all tests for a specific command
cargo test --package nu-cli --test main -- commands::<command_name_here>
-
Check to see if there are code formatting issues
cargo fmt --all -- --check
-
Format the code in the project
cargo fmt --all
Debugging Tips
-
To view verbose logs when developing, enable the
trace
log level.cargo run --release --features=extra -- --log-level trace
-
To redirect trace logs to a file, enable the
--log-target file
switch.cargo run --release --features=extra -- --log-level trace --log-target file open $"($nu.temp-path)/nu-($nu.pid).log"