mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 06:38:43 +02:00
Auto-generate markdown command docs (#4451)
* Finish updating * a couple improvements * Update renames * cleanup examples
This commit is contained in:
@ -1,34 +1,36 @@
|
||||
# for
|
||||
Run a block on each row of the table.
|
||||
---
|
||||
title: for
|
||||
layout: command
|
||||
version: 0.59.0
|
||||
---
|
||||
|
||||
## Usage
|
||||
```shell
|
||||
> for <var> <in> <value> <block> {flags}
|
||||
```
|
||||
Loop over a range
|
||||
|
||||
## Signature
|
||||
|
||||
```> for (var_name) (range) (block) --numbered```
|
||||
|
||||
## Parameters
|
||||
* `<var>` the name of the variable
|
||||
* `<in>` the word 'in'
|
||||
* `<value>` the value we want to iterate
|
||||
* `<block>` the block to run on each item
|
||||
|
||||
## Flags
|
||||
* -h, --help: Display this help message
|
||||
* -n, --numbered: returned a numbered item ($it.index and $it.item)
|
||||
- `var_name`: name of the looping variable
|
||||
- `range`: range of the loop
|
||||
- `block`: the block to run
|
||||
- `--numbered`: returned a numbered item ($it.index and $it.item)
|
||||
|
||||
## Examples
|
||||
Echo the square of each integer
|
||||
|
||||
Echo the square of each integer
|
||||
```shell
|
||||
> for x in [1 2 3] { $x * $x }
|
||||
```
|
||||
```
|
||||
|
||||
Work with elements of a range
|
||||
Work with elements of a range
|
||||
```shell
|
||||
> for $x in 1..3 { $x }
|
||||
```
|
||||
```
|
||||
|
||||
Number each item and echo a message
|
||||
Number each item and echo a message
|
||||
```shell
|
||||
> for $it in ['bob' 'fred'] --numbered { $"($it.index) is ($it.item)" }
|
||||
```
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user