![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | formatting command syntax like get-help or get-command i'm trying to work out how to format the maml help objects like get-help or get-command does, in the example same format.. here is my code so far, however in all cases it doesn't behave exactly the same, in some cases it doesn't put enough brackets around, and in cases when there is a parameter without a value, it puts double brackets. i've looked in the help.format.ps1xml to try to work out hte same logic but still got a few things wrong. so i figured i'd put it out here for the community and MS people to look at.. the benefit is when its done i'll release and blog my whole mamlhelp -> richHTML code, that i'll be incorporating into powershell analyzer.. #region syntax $help = get-Help get-Command -full ($help.syntax) | % { $_.syntaxitem } | % { $str = "";$("$($_.name) " $_ | % { $_.parameter | % { $myp = $_;$_.psobject | % { if ($_.properties["required"].value -ne "true") { "[" } if (($_.properties["position"].value -ne $()) -and ($_.properties["position"].value -ne "") ) { "[" } "-";$_.properties["name"].value if (($_.properties["position"].value -ne $()) -and ($_.properties["position"].value -ne "")) { "]" } if ($_.properties["parametervalue"] -ne $() ) { '<' + $_.properties["parametervalue"].value + '>' } if ($_.properties["parametervaluegroup"] -ne $() ) { "{" $_.properties["parametervaluegroup"].value | % { $i=0; $out=""; foreach($a in $_.parametervalue) { if($i -gt 0) { $out = $out + " | "; } $out = $out + "<" + $a + ">"; $i = $i + 1; } $out; } "}" } if ($_.properties["required"].value -ne "true") { "] " } } } } ) | % { $str = $str + $_ } ; $str } #endregion |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: formatting command syntax like get-help or get-command No bites? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| syntax error in command prompt? | General Discussion | |||
| Help with syntax error in command prompt? | Gaming | |||
| Command line option syntax error. Type /? for Help | Vista mail | |||
| Formatting Inline for Export-CliXML Command | PowerShell | |||
| Powershell.exe command-line syntax | PowerShell | |||