Skip to content

Commit 925e796

Browse files
Restore usage examples, fix help discovery command, drop Contributing
1 parent 9852fc1 commit 925e796

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Ast
22

3-
Ast is a PowerShell module for using the PowerShell abstract syntax tree to analyze PowerShell code.
3+
Ast is a PowerShell module for using the PowerShell abstract syntax tree (AST) to analyze PowerShell code. It provides
4+
commands to extract functions, commands, aliases, comments, and script structure from a file, a string of script content,
5+
or an existing AST object.
46

57
## Installation
68

@@ -11,6 +13,31 @@ Install-PSResource -Name Ast
1113
Import-Module -Name Ast
1214
```
1315

16+
## Usage
17+
18+
The commands accept a file path (`-Path`), inline script content (`-Script`), or an existing AST object (`-Ast`), and
19+
default to matching everything so you can narrow the results with `-Name`.
20+
21+
### Example: List the functions defined in a script
22+
23+
```powershell
24+
Get-AstFunction -Path ./MyScript.ps1
25+
Get-AstFunctionName -Path ./MyScript.ps1
26+
```
27+
28+
### Example: Find the commands invoked by a script
29+
30+
```powershell
31+
Get-AstCommand -Path ./MyScript.ps1
32+
Get-AstCommand -Script "Get-Process; Write-Host 'Hello'"
33+
```
34+
35+
### Example: Inspect a single function by name
36+
37+
```powershell
38+
Get-AstFunction -Path ./MyScript.ps1 -Name 'Test-Me'
39+
```
40+
1441
## Documentation
1542

1643
Documentation is published at [psmodule.io/Ast](https://psmodule.io/Ast/).
@@ -19,9 +46,9 @@ Use PowerShell help and command discovery for module details:
1946

2047
```powershell
2148
Get-Command -Module Ast
22-
Get-Help <CommandName> -Examples
49+
Get-Help -Name Get-AstFunction -Examples
2350
```
2451

25-
## Contributing
52+
## Related tools
2653

27-
Issues and pull requests are welcome. Please use the repository issue tracker to report bugs, request features, or discuss improvements.
54+
- [lzybkr/ShowPSAst](https://github.com/lzybkr/ShowPSAst) — an interactive viewer for exploring the PowerShell AST.

0 commit comments

Comments
 (0)