Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

formatting command syntax like get-help or get-command

Closed Thread
 
Thread Tools Display Modes
Old 10-17-2006   #1 (permalink)
klumsy@xtra.co.nz
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

Old 10-18-2006   #2 (permalink)
klumsy@xtra.co.nz
Guest


 

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

No bites?

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line Ren (Rename) command broken? SixSigmaGuy Vista General 5 05-20-2008 05:52 AM
Command line option syntax error. Type /? for Help Antojak Vista mail 0 01-28-2008 03:28 AM
"invalid STORE command syntax invalid message set syntax" Catullus Nacakus Vista mail 6 01-26-2008 05:46 PM
Formatting Inline for Export-CliXML Command Brandon Shell PowerShell 14 09-18-2007 10:56 PM
Powershell.exe command-line syntax EnigmaticSoul PowerShell 4 03-29-2007 08:40 PM








Vistax64.com 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 2005-2008

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 47 48 49 50