Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21509dc

Browse files
pyranotahcourdent
andauthored
Add Nu lang docs + changelog (windmill-labs#852)
* docs: nu * remove leftovers * update sidebars.js * update docs * update according to parser rewrite * update changelog --------- Co-authored-by: Henri Courdent <[email protected]>
1 parent d4bf293 commit 21509dc

File tree

14 files changed

+168
-17
lines changed

14 files changed

+168
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
slug: nu-lang-support
3+
version: v1.479.0
4+
title: Nushell
5+
tags: ['Nushell', 'Nu', 'Code editor']
6+
description: Nu is cross-platform and statically typed shell written in Rust. Now shipped to windmill
7+
features:
8+
[
9+
'Write your Windmill script in Nu.',
10+
'Run your Nu scripts locally or in the cloud.',
11+
]
12+
image: ./nu-lang.png
13+
docs: docs/getting_started/scripts_quickstart/bash/#nu
14+
---
Loading

docs/advanced/4_local_development/index.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ But what if you want to create a new script from scratch? It's also easy, just c
209209
| MS SQL Server | `.ms.sql` |
210210
| GraphQL | `.gql` |
211211
| PowerShell | `.ps1` |
212+
| Nu | `.nu` |
212213

213214
</details>
214215

@@ -315,4 +316,4 @@ To [run scripts locally](../4_local_development/run_locally.mdx), you will need
315316
description="Run scripts locally that interact with a Windmill instance."
316317
href="/docs/advanced/local_development/run_locally"
317318
/>
318-
</div>
319+
</div>

docs/advanced/6_imports/index.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ e.g.:
123123
```powershell
124124
Import-Module -Name MyModule
125125
```
126+
## Imports in Nu
127+
128+
For [Nu](../../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx#nu) you can import stdlib.
129+
130+
e.g.:
131+
132+
```python
133+
use std
134+
```
126135

127136
## Dependencies on Local development
128137

docs/core_concepts/2_variables_and_secrets/index.mdx

+8-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ $Headers = @{
184184
Invoke-RestMethod -Headers $Headers -Uri "$Env:BASE_INTERNAL_URL/api/w/$Env:WM_WORKSPACE/variables/get/u/user/foo"
185185
```
186186

187-
The last examples in bash and PowerShell showcase well how it works under the hood: It fetches the secret from the API using the job's permissions through the ephemeral token passed as an environment variable to the job.
187+
Nu:
188+
189+
```python
190+
get_variable u/user/foo
191+
```
192+
193+
Examples in bash and PowerShell showcase well how it works under the hood: It fetches the secret from the API using the job's permissions through the ephemeral token passed as an environment variable to the job.
188194

189195
## Mocked API files
190196

@@ -196,4 +202,4 @@ Simulate API interactions locally by using a JSON file to store and retrieve var
196202
description="Simulate API interactions locally by using a JSON file to store and retrieve variables and resources."
197203
href="/docs/advanced/local_development/#mocked-api-files"
198204
/>
199-
</div>
205+
</div>

docs/core_concepts/3_resources_and_types/index.mdx

+7-1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ $Headers = @{
399399
Invoke-RestMethod -Headers $Headers -Uri "$Env:BASE_INTERNAL_URL/api/w/$Env:WM_WORKSPACE/resources/get/u/user/foo"
400400
```
401401

402+
Nu:
403+
404+
```python
405+
get_resource u/user/foo
406+
```
407+
402408
![Fetch resource](./fetch_resource.png.webp)
403409

404410
### Resources in Apps
@@ -451,4 +457,4 @@ Simulate API interactions locally by using a JSON file to store and retrieve var
451457
description="Simulate API interactions locally by using a JSON file to store and retrieve variables and resources."
452458
href="/docs/advanced/local_development/#mocked-api-files"
453459
/>
454-
</div>
460+
</div>

docs/core_concepts/9_worker_groups/index.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ The tags of _default_ worker group are:
129129
- `rust`: The default worker group for [Rust](../../getting_started/0_scripts_quickstart/9_rust_quickstart/index.mdx) scripts.
130130
- `ansible`: The default worker group for [Ansible](../../getting_started/0_scripts_quickstart/10_ansible_quickstart/index.mdx) scripts.
131131
- `csharp`: The default worker group for [C#](../../getting_started/0_scripts_quickstart/11_csharp_quickstart/index.mdx) scripts.
132+
- `nu`: The default worker group for [Nu scripts](../../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx#nu).
132133
- `other`: Everything else (other than the [native](#native-worker-group) tags).
133134

134135
#### Native worker group

docs/core_concepts/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ All details & features on [Pricing page](/pricing).
646646
/>
647647
<DocCard
648648
title="Windows workers"
649-
description="Windows Native Workers are a Self-Hosted Enterprise Feature. You can use the Windows worker natively if you do not want to run Docker or WSL on Windows (e.g., for policy or security reasons). This feature supports the **Python**, **Bun**, and **PowerShell** executors."
649+
description="Windows Native Workers are a Self-Hosted Enterprise Feature. You can use the Windows worker natively if you do not want to run Docker or WSL on Windows (e.g., for policy or security reasons). This feature supports the **Python**, **Bun**, **PowerShell** and **Nu** executors."
650650
href="/docs/misc/windows_workers"
651651
/>
652652
<DocCard

docs/flows/3_editor_components.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ You can either create a new action script in:
307307
- [TypeScript](../getting_started/0_scripts_quickstart/1_typescript_quickstart/index.mdx): Windmill uses Deno as the TypeScript runtime.
308308
- [Go](../getting_started/0_scripts_quickstart/3_go_quickstart/index.mdx).
309309
- [Bash](../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx).
310+
- [Nu](../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx).
310311
- Any language [running any docker container](../advanced/7_docker/index.mdx) through Windmill's bash support.
311312

312313
There are special kinds of scripts, [SQL and query languages](../getting_started/0_scripts_quickstart/5_sql_quickstart/index.mdx):
@@ -438,4 +439,4 @@ The result and logs are displayed on the left-hand side.
438439
href="/docs/core_concepts/instant_preview"
439440
color="teal"
440441
/>
441-
</div>
442+
</div>

docs/getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx

+98-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import DocCard from '@site/src/components/DocCard';
77
import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99

10-
# Bash / PowerShell quickstart
10+
# Bash / PowerShell / Nu quickstart
1111

12-
In this quick start guide, we will write our first script in Bash and PowerShell.
12+
In this quick start guide, we will write our first script in Bash, PowerShell or Nu.
1313

1414
<video
1515
className="border-2 rounded-lg object-cover w-full h-full dark:border-gray-800"
@@ -53,7 +53,7 @@ Scripts consist of 2 parts:
5353

5454
When stored in a code repository, those 2 parts are stored separately at `<path>.sh` and `<path>.script.yaml`.
5555

56-
Below is a simple example of a script built in Bash/Powershell with Windmill:
56+
Below is a simple example of a script built in Bash/Powershell/Nu with Windmill:
5757

5858
<Tabs className="unique-tabs">
5959
<TabItem value="bash" label="Bash" attributes={{className: "text-xs p-4 !mt-0 !ml-0"}}>
@@ -86,6 +86,22 @@ if ($status_code -like "2*" -or $status_code -like "3*") {
8686
Write-Host "The URL is not reachable."
8787
}
8888
```
89+
</TabItem>
90+
<TabItem value="nu" label="Nu" attributes={{className: "text-xs p-4 !mt-0 !ml-0"}}>
91+
92+
```python
93+
def main [
94+
url: string = "default value"
95+
] {
96+
try {
97+
# Nu will throw an error automatically if request fails
98+
http get $url
99+
echo "The URL is reachable!"
100+
} catch {
101+
echo "The URL is not reachable."
102+
}
103+
}
104+
```
89105

90106
</TabItem>
91107
</Tabs>
@@ -184,6 +200,76 @@ Default arguments can be specified using the syntax above: `$argument_name = "It
184200

185201
The last line of the output, here `Write-Output "Hello $Msg"`, is the return value, which might be useful if the script is used in a [flow](../../../flows/1_flow_editor.mdx) or [app](../../../apps/0_app_editor/index.mdx) to pass its result on.
186202

203+
### Nu
204+
205+
Unlike `Bash` and `PowerShell`, `Nu` requires main function and all arguments should defined in signature.
206+
It supports typed, optional and default arguments.
207+
208+
<Tabs className="unique-tabs">
209+
<TabItem value="simple" label="Simple" attributes={{className: "text-xs p-4 !mt-0 !ml-0"}}>
210+
211+
```python
212+
def main [ msg, dflt = "default value", nb: number = 3 ] {
213+
echo $"Hello ($msg)"
214+
}
215+
```
216+
</TabItem>
217+
<TabItem value="complete" label="Complete" attributes={{className: "text-xs p-4 !mt-0 !ml-0"}}>
218+
219+
```python
220+
use std assert
221+
# Nushell
222+
# A new type of shell
223+
def main [
224+
no_default: string,
225+
name = "Nicolas Bourbaki",
226+
age: int = 42,
227+
date_of_birth?: datetime,
228+
obj: record = {"records": "included"},
229+
l: list<string> = ["or", "lists!"],
230+
tables?: table,
231+
enable_kill_mode?: bool = true,
232+
] {
233+
# Test
234+
# https://www.nushell.sh/book/testing.html
235+
assert ($age == 42)
236+
237+
print $"Hello World and a warm welcome especially to ($name)"
238+
print "and its acolytes.." $age $obj $l
239+
print $tables
240+
241+
let secret = try {
242+
get_variable f/examples/secret
243+
} catch {
244+
'No secret yet at f/examples/secret !'
245+
};
246+
247+
print $"The variable at \`f/examples/secret\`: ($secret)"
248+
# fetch context variables
249+
let user = $env.WM_USERNAME
250+
251+
# Nu pipelines
252+
ls | where size > 1kb | sort-by modified | print "ls:" $in
253+
254+
# Nu works with existing data
255+
# Nu speaks JSON, YAML, SQLite, Excel, and more out of the box.
256+
# It's easy to bring data into a Nu pipeline whether it's in a file, a database, or a web API:
257+
let nu_license = http get https://api.github.com/repos/nushell/nushell | get license
258+
259+
return { splitted: ($name | split words), user: $user, nu_license: $nu_license}
260+
# Interested in learning more?
261+
# https://www.nushell.sh/book/getting_started.html
262+
263+
```
264+
265+
</TabItem>
266+
</Tabs>
267+
268+
One of the strong sides of `Nu` is that it is cross-platform. If you have linux workers and [windows workers](../../../misc/17_windows_workers/index.mdx)
269+
Nushell scripts will be able to run on both!
270+
271+
If you are interested in `Nu` you can read their [official documentation](https://www.nushell.sh/book/getting_started.html)
272+
187273
## Instant preview & testing
188274

189275
Look at the UI preview on the right: it was updated to match the input
@@ -215,6 +301,13 @@ argument_name="${1:-Its default value}"
215301
$argument_name = "Its default value"
216302
```
217303

304+
</TabItem>
305+
<TabItem value="nu" label="Nu" attributes={{className: "text-xs p-4 !mt-0 !ml-0"}}>
306+
307+
```python
308+
def main [ argument_name = "Its default value" ] { }
309+
```
310+
218311
</TabItem>
219312
</Tabs>
220313

@@ -277,6 +370,8 @@ You can also choose to [run the script from the CLI](../../../advanced/3_cli/ind
277370

278371
The last line returned by the script will be the string result. To use a json result instead, output your result in `./result.json` and it will be automatically picked-up and considered as the JSON result for Bash and Powershell scripts.
279372

373+
For Nu first returned data from main function will be used as a result.
374+
280375
## Run Docker containers
281376

282377
In some cases where your task requires a complex set of dependencies or is implemented in a non-supported language, you can still include it as a flow step or individual script.

docs/getting_started/0_scripts_quickstart/index.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Windmill supports scripts in TypeScript, Python, Go, PHP, Bash, C#, SQL and Rust
3131
Icon={SiPython}
3232
/>
3333
<DocCard
34-
title="Bash / Powershell"
35-
description="Write your first Windmill script in Bash / Powershell."
34+
title="Bash / Powershell / Nu"
35+
description="Write your first Windmill script in Bash / Powershell / Nu."
3636
href="/docs/getting_started/scripts_quickstart/bash"
3737
Icon={SiGnubash}
3838
/>

docs/misc/17_windows_workers/index.mdx

+21-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import DocCard from '@site/src/components/DocCard';
55
Windows Native Workers are a [Self-Hosted Enterprise](/pricing) Feature.
66

77
You can use the Windows worker natively if you do not want to run Docker or WSL on Windows (e.g., for policy or security reasons).
8-
This feature supports the **Python**, **Bun**, and **PowerShell** executors.
8+
This feature supports the **Python**, **Bun**, **PowerShell** and **Nu** executors.
99

1010
You can connect Windows workers to your existing Dockerized or cloud self-hosted PostgreSQL database and Windmill server.
1111

@@ -62,9 +62,7 @@ You can also check other installation methods in uv`s [official documentation](h
6262
# Replace these variables with your specific configuration
6363
$env:BUN_PATH="C:\Users\Alex\.bun\bin\bun.exe"
6464
```
65-
6665
### PowerShell executor
67-
6866
1. **Install PowerShell 7+ (stable)**: Ensure you have the latest stable release of PowerShell by following the [official documentation](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows).
6967
- Start PowerShell 7 and verify you're running PowerShell 7 by checking `$PSVersionTable`:
7068
```powershell
@@ -88,3 +86,23 @@ You can also check other installation methods in uv`s [official documentation](h
8886
# Replace these variables with your specific configuration
8987
$env:POWERSHELL_PATH="C:\Program Files\PowerShell\7\pwsh.exe"
9088
```
89+
### Nu executor
90+
91+
1. **Nu**: Ensure you have installed Nu by following the [official documentation](https://www.nushell.sh/book/installation.html#package-managers).
92+
- Start PowerShell and verify you can enter Nushell:
93+
```powershell
94+
nu
95+
```
96+
97+
2. **Locate Nu installation**:
98+
- Find where Nu is installed by running:
99+
```powershell
100+
where.exe nu.exe
101+
```
102+
103+
3. **Set environment variables**:
104+
- Add the following environment variables (replace the placeholders with your specific values):
105+
```powershell
106+
# Replace these variables with your specific configuration
107+
$env:NU_PATH="C:\..\..\nu.exe"
108+
```

docs/script_editor/settings.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Language of the script. Windmill supports:
5050
- [TypeScript](../getting_started/0_scripts_quickstart/1_typescript_quickstart/index.mdx) (Bun & Deno)
5151
- [Python](../getting_started/0_scripts_quickstart/2_python_quickstart/index.mdx)
5252
- [Go](../getting_started/0_scripts_quickstart/3_go_quickstart/index.mdx)
53-
- [Bash & Powershell](../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx)
53+
- [Bash & Powershell & Nu](../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx)
5454
- [SQL](../getting_started/0_scripts_quickstart/5_sql_quickstart/index.mdx) (PostgreSQL, MySQL, MS SQL, BigQuery, Snowflake)
5555
- [Rest & GraphQL](../getting_started/0_scripts_quickstart/6_rest_grapqhql_quickstart/index.mdx)
5656
- [Docker](../getting_started/0_scripts_quickstart/7_docker_quickstart/index.mdx)

sidebars.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const sidebars = {
3838
{
3939
type: 'doc',
4040
id: 'getting_started/scripts_quickstart/bash_quickstart/index',
41-
label: 'Bash / PowerShell'
41+
label: 'Bash / PowerShell / Nu'
4242
},
4343
{
4444
type: 'doc',
@@ -79,7 +79,7 @@ const sidebars = {
7979
type: 'doc',
8080
id: 'getting_started/scripts_quickstart/csharp_quickstart/index',
8181
label: 'C#'
82-
}
82+
},
8383
]
8484
},
8585
{

0 commit comments

Comments
 (0)