http://hagenlocher.org/software/PythonCmdlet.zip
This is a sample project that shows one approach to creating a PowerShell cmdlet using IronPython. The cmdlet object has to derive from System.Management.Automation.Cmdlet, it needs to override particular virtual functions and it needs appropriate attributes on the class and on the properties representing the cmdlet's parameters. Originally, I was hoping to use the project I'm working on[1] to automatically generate an appropriate wrapper from the Python class. Unfortunately, I haven't yet been able to think of a sufficiently clever scheme to handle the scenario where the wrapper needs to be derived from a specific base class, and the Python object can transparently access the members of that same base class despite not having the same object identity. Here, I've taken the approach of passing the actual Cmdlet-derived class as a parameter to the constructor of the Python class. The Python script itself is stored as a resource in the cmdlet. The cmdlet implements a "browse-matches" command that is designed to have MatchInfo objects pipelined into it. Usage would be something like this: select-string NewTypeMaker | browse-matches The results are displayed as simple strings in a listbox on a modal form. Information on installing and using a PowerShell cmdlet can be found (among other places) at http://blog.cumps.be/using-powershell-writing-and-debugging-cmdlets/ This project is based on IronPython 2.0B1. 1: http://www.codeplex.com/coils -- not forgotten, but currently held up by an unresolved "strongly-named assembly is required" that I'm trying to work around. -- Curt Hagenlocher [EMAIL PROTECTED]
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
