Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - formatting command syntax like get-help or get-command

Reply
 
Old 10-17-2006   #1 (permalink)
klumsy@xtra.co.nz


 
 

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 SpecsSystem Spec
Old 10-18-2006   #2 (permalink)
klumsy@xtra.co.nz


 
 

Re: formatting command syntax like get-help or get-command

No bites?

My System SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46