|
3 | 3 | ## Table of content
|
4 | 4 | - [*installation*](#recycle-installation-toc)
|
5 | 5 | - [*configuration*](#gear-configuration-toc)
|
| 6 | +- [*usage*](#rocket-usage-toc) |
| 7 | + - [*install a package*](#install-a-package-toc) |
| 8 | + - [*update a package*](#update-a-package-toc) |
| 9 | + - [*define a package*](#define-a-package-toc) |
6 | 10 | - [*running a test suite*](#test_tube-running-a-test-suite-toc)
|
7 |
| - - [*run the tests*](#run-the-tests-of-Nupm-toc) |
| 11 | + - [*run the tests*](#run-the-tests-of-Nupm-toc) |
8 | 12 | - [*design*](#memo-design-of-nupm-toc)
|
9 | 13 |
|
10 | 14 | :warning: **This project is in an experimentation stage and not intended for serious use!** :warning:
|
|
20 | 24 | Both of the above commands will make `nupm` and all its subcommands available in your current scope. `overlay use` will allow you to `overlay hide` the `nupm` overlay when you don't need it.
|
21 | 25 |
|
22 | 26 | > **Note**
|
23 |
| -> `nupm` is able to install itself: from inside the root of your local copy of `nupm`, run |
| 27 | +> `nupm` is able to install itself: from outside the root of your local copy of `nupm`, run |
24 | 28 | > ```nushell
|
25 |
| -> use nupm/ |
26 |
| -> nupm install --force --path . |
| 29 | +> use nupm/nupm |
| 30 | +> nupm install nupm --force --path |
27 | 31 | > ```
|
28 | 32 |
|
29 | 33 | ## :gear: configuration [[toc](#table-of-content)]
|
@@ -52,6 +56,51 @@ $env.PATH = (
|
52 | 56 | )
|
53 | 57 | ```
|
54 | 58 |
|
| 59 | +## :rocket: usage [[toc](#table-of-content)] |
| 60 | + |
| 61 | +Nupm can install different types of packages, such as modules and scripts. It also provides a mechanism for a custom installation using a `build.nu` file. |
| 62 | + |
| 63 | +As an illustrative example, the following demonstrates use of a fictional `foo` module-based package. |
| 64 | + |
| 65 | +### install a package [[toc](#table-of-content)] |
| 66 | + |
| 67 | +```nushell |
| 68 | +git clone https://github.com/nushell/foo.git |
| 69 | +nupm install foo --path |
| 70 | +``` |
| 71 | + |
| 72 | +### update a package [[toc](#table-of-content)] |
| 73 | + |
| 74 | +Assuming the repository is already cloned, you can update the module package with the following: |
| 75 | + |
| 76 | +```nushell |
| 77 | +do { cd foo; git pull } |
| 78 | +nupm install foo --force --path |
| 79 | +``` |
| 80 | +This usage will likely change once a dedicated `nupm update` command is added. |
| 81 | + |
| 82 | +### define a package [[toc](#table-of-content)] |
| 83 | + |
| 84 | +In order to use a module-based package with Nupm, a directory should be structured similar to the following `foo` module: |
| 85 | + |
| 86 | +- `foo/` |
| 87 | + - `mod.nu` |
| 88 | + - (other scripts and modules) |
| 89 | +- `nupm.nuon` |
| 90 | + |
| 91 | +The `nupm.nuon` file is a metadata file that describes the package. It should contain the following fields: |
| 92 | + |
| 93 | +```nushell |
| 94 | +{ |
| 95 | + name: "foo" |
| 96 | + description: "A package that demonstrates use of Nupm" |
| 97 | + type: "module" |
| 98 | + license: "MIT" |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +Nupm also supports other types of packages. See [Project Structure](https://github.com/nushell/nupm/blob/main/docs/design/README.md#project-structure-toc) for more details. |
| 103 | + |
55 | 104 | ## :test_tube: running a test suite [[toc](#table-of-content)]
|
56 | 105 | as it is done in Nupm, one can define tests in a project and run them with the `nupm test` command:
|
57 | 106 | - create a Nushell package with a `nupm.nuon` file, let's call this example package `package`
|
|
0 commit comments