MartinGC94 / UsefulArgumentCompleters

MIT License
9 stars 1 forks source link

Documentation needed #1

Closed jdhitsolutions closed 2 years ago

jdhitsolutions commented 2 years ago

Because your module doesn't have any public commands, and it is practically impossible to identify argument completers, it would be very helpful to include documentation such as an about_usefulargumentcompleters to identify. Or store your completer information in a data file, cmdlet name and parameter should all be that you'd need, and write a module function like Get-UsefulArgumentCompleters.

MartinGC94 commented 2 years ago

Agreed, it would be useful to document all the completers but don't you think it would be more appropriate to document it here and/or the PowerShell gallery instead of the module itself?
I would imagine most people would check out the available completers when they are deciding if it's worth installing the module or not and then never really think about it afterwards. I mean if you are wondering if command X is supported, wouldn't you just type in Command -Param <Tab> and see if it works instead of first checking it with a command or Get-Help?

I'm thinking the easiest solution to maintaining a list is to include a step in the build script that finds all instances of Register-ArgumentCompleter and exports the command/parameter names (sorted) to a CSV that people can look through if they want. Github has a pretty nice viewer for CSV files but unfortunately the PS gallery doesn't even let you preview CSV files so maybe I need to also export it to a psd1 file for easy previews from the PS gallery.

jdhitsolutions commented 2 years ago

I think you need to provide information in GitHub, as part of the README makes the most sense. That could double as an about help topic. I also think you can easily build a module command to list your completers. I had the same thought about parsing your files. Build a CSV and have your function import the CSV and create a custom object.

jdhitsolutions commented 2 years ago

Here's a quick and dirty proof-of-concept using regex to parse your files.

 [regex]$rx = "Register\-ArgumentCompleter \-CommandName (?<command>[\w-]*) \-ParameterName (?<param>\w*)"
$c = Get-Content C:\work\rac.ps1
$m = $rx.match($c)
[pscustomobject]@{
    Command = $m.groups["command"].value
    Parameter = $m.groups["param"].value
}

#output
Command         Parameter
-------         ---------
Get-AppxPackage Publisher
MartinGC94 commented 2 years ago

Thanks for the suggestion. I've resolved it with release 1.0.8, seen in this commit: https://github.com/MartinGC94/UsefulArgumentCompleters/commit/571140461ea1eaac4fe0d8fe8f332c99ca5f888d

You can view the available argument completers here: https://github.com/MartinGC94/UsefulArgumentCompleters/blob/main/ArgumentCompleters.csv and in the shell by typing in: Get-UsefulArgumentCompleter.