Skip to content

Commit 439a177

Browse files
authored
Setup Repo (#1)
This PR sets up the repo with everything we talked about for example plugins in [our meeting](https://hackmd.io/@nucore/HJjIrukRkl#Discussed-Topics). It adds the following plugins: - `nu_plugin_node_example` - `nu_plugin_nu_example` - `nu_plugin_python_example` - `nu_plugin_custom_values` - `nu_plugin_example` I’ve barely touched them, so they should behave just like before. To make version handling easier, I moved the versions into their own files. The `.python-version` and `.node-version` files should make sure script-based plugins run with the expected runtime versions.
1 parent 9e00c6c commit 439a177

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3394
-0
lines changed

.github/workflows/ci.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: continuous-integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: '0 7 * * *' # daily at 07:00 UTC
10+
11+
env:
12+
testing-file: https://raw.githubusercontent.com/nushell/nushell/6a759abcbd9bdc6fb4bbd60144e309bd1a79786b/crates/nu-std/testing.nu
13+
14+
jobs:
15+
build-nu:
16+
name: Build Nushell from `main`
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout Nushell `main` branch
20+
uses: actions/checkout@v4
21+
with:
22+
repository: nushell/nushell
23+
24+
- name: Setup Rust toolchain
25+
uses: actions-rust-lang/setup-rust-toolchain@v1
26+
27+
- name: Build Nushell binary
28+
run: cargo build --release --bin nu
29+
30+
- name: Upload Nushell binary
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: nu
34+
path: target/release/nu
35+
if-no-files-found: error
36+
37+
38+
test-plugin:
39+
name: "Test Plugin: ${{ matrix.plugin.name }}"
40+
needs: build-nu
41+
runs-on: ubuntu-latest
42+
43+
strategy:
44+
matrix:
45+
plugin:
46+
- name: nu_plugin_node_example
47+
plugin: ./javascript/nu_plugin_node_example/nu_plugin_node_example.js
48+
tests-dir: ./javascript/nu_plugin_node_example
49+
needs:
50+
- node
51+
- name: nu_plugin_nu_example
52+
plugin: ./nushell/nu_plugin_nu_example/nu_plugin_nu_example.nu
53+
tests-dir: ./nushell/nu_plugin_nu_example
54+
needs:
55+
- nushell
56+
- name: nu_plugin_python_example
57+
plugin: ./python/nu_plugin_python_example/nu_plugin_python_example.py
58+
tests-dir: ./python/nu_plugin_python_example
59+
needs:
60+
- python
61+
- name: nu_plugin_example
62+
plugin: ./target/release/nu_plugin_example
63+
tests-dir: ./rust/nu_plugin_example
64+
needs:
65+
- rust
66+
- name: nu_plugin_custom_values
67+
plugin: ./target/release/nu_plugin_custom_values
68+
tests-dir: ./rust/nu_plugin_custom_values
69+
needs:
70+
- rust
71+
72+
steps:
73+
- name: Checkout Repo
74+
uses: actions/checkout@v4
75+
76+
- if: contains(matrix.plugin.needs, 'node')
77+
name: Setup Node
78+
uses: volta-cli/action@v4
79+
80+
- if: contains(matrix.plugin.needs, 'nushell')
81+
name: Setup Nushell
82+
uses: hustcer/setup-nu@v3
83+
84+
- if: contains(matrix.plugin.needs, 'python')
85+
name: Setup Python
86+
uses: actions/setup-python@v5
87+
with:
88+
python-version-file: ".python-version"
89+
90+
- if: contains(matrix.plugin.needs, 'rust')
91+
name: Setup Rust toolchain and cache
92+
uses: actions-rust-lang/setup-rust-toolchain@v1
93+
94+
- if: contains(matrix.plugin.needs, 'rust')
95+
name: Build Rust-based Plugin
96+
run: cargo build --release --package ${{ matrix.plugin.name }}
97+
98+
- name: Download Nushell Binary
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: nu
102+
103+
- name: Ensure Nushell binary is executable
104+
run: chmod +x ./nu
105+
106+
- name: Download testing.nu
107+
run: wget ${{ env.testing-file }}
108+
109+
- name: Ensure plugin is executable
110+
run: chmod +x ${{ matrix.plugin.plugin }}
111+
112+
- name: Run tests
113+
run: ./nu -n -c 'use testing.nu; testing run-tests --path ${{ matrix.plugin.tests-dir }} --plugins ["${{ matrix.plugin.plugin }}"]'
114+
115+
- if: contains(matrix.plugin.needs, 'rust')
116+
name: Run Rust-based tests
117+
run: cargo test --package ${{ matrix.plugin.name }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target
2+
Cargo.lock
3+
4+
/.venv
5+
__pycache__

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.14

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
resolver = "3"
3+
members = [
4+
"rust/nu_plugin_custom_values",
5+
"rust/nu_plugin_example",
6+
]
7+
8+
[workspace.dependencies]
9+
nu-plugin = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
10+
nu-protocol = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
11+
nu-plugin-test-support = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
12+
nu-cmd-lang = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
13+
14+
serde = "1.0"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 - 2025 The Nushell Project Developers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# nushell/plugin-examples
2+
[![Nushell](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fnushell%2Fplugin-examples%2Frefs%2Fheads%2Fsetup%2FCargo.toml&query=workspace.dependencies.nu-protocol.version&prefix=v&label=nushell&color=%234E9906)](https://github.com/nushell/nushell)
3+
[![Build Status](https://img.shields.io/github/actions/workflow/status/nushell/plugin-examples/ci.yml)](https://github.com/nushell/plugin-examples/actions)
4+
5+
Plugin examples for Nushell in different languages.
6+
7+
## About
8+
This repo has example Nushell plugins written in different languages.
9+
Each plugin is tested daily via CI against the latest `main` branch of
10+
[nushell](https://github.com/nushell/nushell).
11+
You can use them as a starting point for building your own plugin.
12+
13+
For more real plugins, check out
14+
[nushell/awesome-nu](https://github.com/nushell/awesome-nu?tab=readme-ov-file#plugins).
15+
16+
## Plugins
17+
Plugins are organized by language (e.g. `rust/`) and live in their own folders.
18+
Each folder usually includes:
19+
- a test file
20+
- a `.cmd` file if the plugin needs a scripting runtime (helps with local testing on Windows)
21+
22+
Every plugin is also listed in the [CI workflow](./.github/workflows/ci.yml) to
23+
ensure it gets tested regularly.
24+
25+
## Write your own plugin
26+
27+
This repo contains examples of how to implement specific behaviors in Nushell
28+
plugins.
29+
If you want to stream data, return a table, handle arguments, or work with
30+
custom types, there's likely an example here that shows how to do it.
31+
32+
To build your own plugin from scratch:
33+
34+
- Start with our official plugin template for a clean setup:
35+
👉 [nushell/nu_plugin_template](https://github.com/nushell/nu_plugin_template)
36+
37+
- Read the full plugin guide in the Nushell book:
38+
📚 [Plugin guide on nushell.sh](https://www.nushell.sh/contributor-book/plugins.html)
39+
40+
You might need to update the Nushell dependencies in the plugin template,
41+
since it can lag behind the latest
42+
[nushell](https://github.com/nushell/nushell) version.
43+
For more real-world plugins, check out
44+
[nushell/awesome-nu](https://github.com/nushell/awesome-nu?tab=readme-ov-file#plugins).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
node %~dp0nu_plugin_node_example.js %*

0 commit comments

Comments
 (0)