Spec-Zone.ru › Nushell

ast for debug

Print the abstract syntax tree (ast) for a pipeline.

Signature

> ast {flags} (pipeline)

Flags

  • --json, -j: Serialize to json.
  • --minify, -m: Minify the nuon or json output.
  • --flatten, -f: An easier to read version of the ast.

Parameters

  • pipeline: The pipeline to print the ast for.

Input/output types:

input output
nothing table
nothing record
nothing string

Examples

Print the ast of a string.

> ast 'hello'

Print the ast of a pipeline.

> ast 'ls | where name =~ README'

Print the ast of a pipeline with an error.

> ast 'for x in 1..10 { echo $x '

Print the ast of a pipeline with an error, as json, in a nushell table.

> ast 'for x in 1..10 { echo $x ' --json | get block | from json

Print the ast of a pipeline with an error, as json, minified.

> ast 'for x in 1..10 { echo $x ' --json --minify

Print the ast of a string flattened.

> ast "'hello'" --flatten
╭───┬─────────┬──────────────┬───────────────╮
│ # │ content │    shape     │     span      │
├───┼─────────┼──────────────┼───────────────┤
│ 0 │ 'hello' │ shape_string │ ╭───────┬───╮ │
│   │         │              │ │ start │ 0 │ │
│   │         │              │ │ end   │ 7 │ │
│   │         │              │ ╰───────┴───╯ │
╰───┴─────────┴──────────────┴───────────────╯

Print the ast of a string flattened, as json, minified.

> ast "'hello'" --flatten --json --minify
[{"content":"'hello'","shape":"shape_string","span":{"start":0,"end":7}}]

Print the ast of a pipeline flattened.

> ast 'ls | sort-by type name -i' --flatten
╭───┬─────────┬────────────────────┬────────────────╮
│ # │ content │       shape        │      span      │
├───┼─────────┼────────────────────┼────────────────┤
│ 0 │ ls      │ shape_internalcall │ ╭───────┬───╮  │
│   │         │                    │ │ start │ 0 │  │
│   │         │                    │ │ end   │ 2 │  │
│   │         │                    │ ╰───────┴───╯  │
│ 1 │ |       │ shape_pipe         │ ╭───────┬───╮  │
│   │         │                    │ │ start │ 3 │  │
│   │         │                    │ │ end   │ 4 │  │
│   │         │                    │ ╰───────┴───╯  │
│ 2 │ sort-by │ shape_internalcall │ ╭───────┬────╮ │
│   │         │                    │ │ start │ 5  │ │
│   │         │                    │ │ end   │ 12 │ │
│   │         │                    │ ╰───────┴────╯ │
│ 3 │ type    │ shape_string       │ ╭───────┬────╮ │
│   │         │                    │ │ start │ 13 │ │
│   │         │                    │ │ end   │ 17 │ │
│   │         │                    │ ╰───────┴────╯ │
│ 4 │ name    │ shape_string       │ ╭───────┬────╮ │
│   │         │                    │ │ start │ 18 │ │
│   │         │                    │ │ end   │ 22 │ │
│   │         │                    │ ╰───────┴────╯ │
│ 5 │ -i      │ shape_flag         │ ╭───────┬────╮ │
│   │         │                    │ │ start │ 23 │ │
│   │         │                    │ │ end   │ 25 │ │
│   │         │                    │ ╰───────┴────╯ │
╰───┴─────────┴────────────────────┴────────────────╯

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/ast.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API