diff --git a/README.md b/README.md index 0908883..4a9763e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,12 @@ # Ast -A PowerShell module for using the Abstract Syntax Tree (AST) on any PowerShell code. - -## Prerequisites - -This uses the following external resources: -- The [PSModule framework](https://github.com/PSModule) for building, testing and publishing the module. +Ast is a PowerShell module for using the PowerShell abstract syntax tree (AST) to analyze PowerShell code. It provides +commands to extract functions, commands, aliases, comments, and script structure from a file, a string of script content, +or an existing AST object. ## Installation -To install the module from the PowerShell Gallery, you can use the following command: +Install the module from the PowerShell Gallery: ```powershell Install-PSResource -Name Ast @@ -18,39 +15,40 @@ Import-Module -Name Ast ## Usage -Here is a list of example that are typical use cases for the module. - -### Example 1: Get the function name from a script +The commands accept a file path (`-Path`) or inline script content (`-Script`), and default to matching everything so +you can narrow the results with `-Name`. -This example shows how to get the function name from a script. +### Example: List the functions defined in a script ```powershell -Get-AstFunctionName -Path 'Test-Me.ps1' -Test-Me +Get-AstFunction -Path ./MyScript.ps1 +Get-AstFunctionName -Path ./MyScript.ps1 ``` -### Find more examples +### Example: Find the commands invoked by a script -To find more examples of how to use the module, please refer to the [examples](examples) folder. - -Alternatively, you can use the Get-Command -Module 'This module' to find more commands that are available in the module. -To find examples of each of the commands you can use Get-Help -Examples 'CommandName'. +```powershell +Get-AstCommand -Path ./MyScript.ps1 +Get-AstCommand -Script "Get-Process; Write-Host 'Hello'" +``` -## Contributing +### Example: Inspect a single function by name -Coder or not, you can contribute to the project! We welcome all contributions. +```powershell +Get-AstFunction -Path ./MyScript.ps1 -Name 'Test-Me' +``` -### For Users +## Documentation -If you don't code, you still sit on valuable information that can make this project even better. If you experience that the -product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. -Please see the issues tab on this project and submit a new issue that matches your needs. +Documentation is published at [psmodule.io/Ast](https://psmodule.io/Ast/). -### For Developers +Use PowerShell help and command discovery for module details: -If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. -You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement. +```powershell +Get-Command -Module Ast +Get-Help -Name Get-AstFunction -Examples +``` -## Tools +## Related tools -- [lzybkr/ShowPSAst](https://github.com/lzybkr/ShowPSAst) +- [lzybkr/ShowPSAst](https://github.com/lzybkr/ShowPSAst) — an interactive viewer for exploring the PowerShell AST.