|
| 1 | +# Contributing to nu_scripts |
| 2 | + |
| 3 | +Thanks for your interest in contributing to nu_scripts! |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. **Fork** the repository on GitHub. |
| 8 | +2. **Clone** your fork locally. |
| 9 | +3. Create a **new branch** for your changes. |
| 10 | + |
| 11 | +## Development Tools |
| 12 | + |
| 13 | +We provide a `toolkit.nu` module to help with development and validation. You can load it in your shell: |
| 14 | + |
| 15 | +```nu |
| 16 | +use toolkit.nu |
| 17 | +``` |
| 18 | + |
| 19 | +### validating your changes |
| 20 | + |
| 21 | +Before submitting a Pull Request, please run the `check pr` command. This ensures your changes meet our standards and pass all tests. |
| 22 | + |
| 23 | +```nu |
| 24 | +toolkit check pr |
| 25 | +``` |
| 26 | + |
| 27 | +By default, this command acts on **changed files only** (files different from `origin/main`). |
| 28 | + |
| 29 | +### Linting |
| 30 | + |
| 31 | +You can run the linter separately if needed: |
| 32 | + |
| 33 | +```nu |
| 34 | +toolkit lint |
| 35 | +``` |
| 36 | + |
| 37 | +#### check options |
| 38 | + |
| 39 | +Both `check pr` and `lint` support the following flags: |
| 40 | + |
| 41 | +- `--full`: Check **all** files in the repository, not just changed ones. |
| 42 | +- `--and-exit`: Exit with a non-zero exit code if errors are found (useful for CI scripts). |
| 43 | + |
| 44 | +## Testing |
| 45 | + |
| 46 | +While `toolkit check pr` performs linting, it does not currently run logic tests (`toolkit test` is not yet implemented). |
| 47 | + |
| 48 | +If your contribution involves complex logic (e.g., parsing helpers, new modules), we encourage you to create a test script to verify it. You can use the standard library's `std/assert` module for this. |
| 49 | + |
| 50 | +**Note**: Functions and aliases in `.nu` files are not added to the global namespace unless explicitly `source`d or `use`d, so adding test files is safe. |
| 51 | + |
| 52 | +Example `modules/my_feature/tests/test_my_feature.nu`: |
| 53 | +```nu |
| 54 | +use std/assert |
| 55 | +use ../my_feature.nu |
| 56 | +
|
| 57 | +#[test] |
| 58 | +def "feature works as expected" [] { |
| 59 | + assert equal (my_feature "input") "expected output" |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +You can run these tests manually: |
| 64 | +```nu |
| 65 | +nu modules/my_feature/tests/test_my_feature.nu |
| 66 | +``` |
| 67 | + |
| 68 | +## Submitting a Pull Request |
| 69 | + |
| 70 | +1. Push your changes to your fork. |
| 71 | +2. Open a Pull Request against the `main` branch of `nushell/nu_scripts`. |
| 72 | +3. Ensure the CI checks pass. |
0 commit comments