|
1 | 1 | # Lua |
2 | 2 |
|
3 | | -A PowerShell module for converting between PowerShell objects and Lua table notation. |
4 | | - |
5 | | -## Prerequisites |
6 | | - |
7 | | -This uses the following external resources: |
8 | | - |
9 | | -- The [PSModule framework](https://github.com/PSModule/Process-PSModule) for building, testing and publishing the module. |
| 3 | +Lua is a PowerShell module for converting between PowerShell objects and Lua table notation. |
10 | 4 |
|
11 | 5 | ## Installation |
12 | 6 |
|
13 | | -To install the module from the PowerShell Gallery, you can use the following command: |
| 7 | +Install the module from the PowerShell Gallery: |
14 | 8 |
|
15 | 9 | ```powershell |
16 | 10 | Install-PSResource -Name Lua |
17 | 11 | Import-Module -Name Lua |
18 | 12 | ``` |
19 | 13 |
|
20 | | -## Usage |
21 | | - |
22 | | -Here is a list of examples that are typical use cases for the module. |
23 | | - |
24 | | -### Example 1: Convert a PowerShell hashtable to Lua |
25 | | - |
26 | | -```powershell |
27 | | -@{ name = "ElvUI"; version = "13.74"; enabled = $true } | ConvertTo-Lua |
28 | | -
|
29 | | -{ |
30 | | - name = "ElvUI", |
31 | | - version = "13.74", |
32 | | - enabled = true |
33 | | -} |
34 | | -``` |
35 | | - |
36 | | -### Example 2: Convert a Lua table string to a PowerShell object |
37 | | - |
38 | | -```powershell |
39 | | -$lua = '{ name = "ElvUI", version = "13.74", enabled = true }' |
40 | | -$config = $lua | ConvertFrom-Lua |
41 | | -$config.name # ElvUI |
42 | | -$config.enabled # True |
43 | | -``` |
44 | | - |
45 | | -### Example 3: Read a Lua file and convert to PowerShell |
46 | | - |
47 | | -```powershell |
48 | | -$luaContent = Get-Content -Path 'config.lua' -Raw |
49 | | -$config = ConvertFrom-Lua -InputObject $luaContent |
50 | | -$config.unitframes.playerWidth # 270 |
51 | | -``` |
52 | | - |
53 | | -### Example 4: Convert a PowerShell object to compressed Lua |
54 | | - |
55 | | -```powershell |
56 | | -@(1, 2, 3) | ConvertTo-Lua -Compress |
57 | | -
|
58 | | -{1,2,3} |
59 | | -``` |
60 | | - |
61 | | -### Example 5: Round-trip JSON to Lua |
62 | | - |
63 | | -```powershell |
64 | | -$data = Get-Content -Path 'settings.json' -Raw | ConvertFrom-Json |
65 | | -$luaOutput = $data | ConvertTo-Lua |
66 | | -$luaOutput | Set-Content -Path 'settings.lua' |
67 | | -``` |
68 | | - |
69 | | -### Example 6: Convert Lua to PSCustomObject |
70 | | - |
71 | | -```powershell |
72 | | -$result = '{ server = "localhost", port = 8080 }' | ConvertFrom-Lua |
73 | | -$result.server # localhost |
74 | | -$result.port # 8080 |
75 | | -``` |
76 | | - |
77 | | -### Find more examples |
78 | | - |
79 | | -To find more examples of how to use the module, please refer to the [examples](examples) folder. |
80 | | - |
81 | | -Alternatively, you can use `Get-Command -Module 'Lua'` to find commands available in the module. |
82 | | -To find examples of each command, use `Get-Help -Examples 'CommandName'`. |
83 | | - |
84 | 14 | ## Documentation |
85 | 15 |
|
86 | | -For detailed documentation on each function, use the built-in help system: |
| 16 | +Documentation is published at [psmodule.io/Lua](https://psmodule.io/Lua/). |
| 17 | + |
| 18 | +Use PowerShell help and command discovery for module details: |
87 | 19 |
|
88 | 20 | ```powershell |
89 | | -Get-Help ConvertTo-Lua -Full |
90 | | -Get-Help ConvertFrom-Lua -Full |
| 21 | +Get-Command -Module Lua |
| 22 | +Get-Help <CommandName> -Examples |
91 | 23 | ``` |
92 | 24 |
|
93 | 25 | ## Contributing |
94 | 26 |
|
95 | | -Coder or not, you can contribute to the project! We welcome all contributions. |
96 | | - |
97 | | -### For users |
98 | | - |
99 | | -If you don't code, you still sit on valuable information that can make this project even better. If you experience that the |
100 | | -product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. |
101 | | -Please see the issues tab on this project and submit a new issue that matches your needs. |
102 | | - |
103 | | -### For developers |
104 | | - |
105 | | -If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. |
106 | | -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. |
| 27 | +Issues and pull requests are welcome. Please use the repository issue tracker to report bugs, request features, or discuss improvements. |
0 commit comments