endjin-gists.psm1
|
# <copyright file="endjin-gists.psm1" company="Endjin Limited"> # Copyright (c) Endjin Limited. All rights reserved. # </copyright> $script:VendirVersion = '0.45.1' # find all the functions that make-up this module $functions = Get-ChildItem -Recurse $PSScriptRoot/functions -Include *.ps1 | ` Where-Object { $_ -notmatch ".Tests.ps1" } # dot source the individual scripts that make-up this module foreach ($function in ($functions)) { . $function.FullName } # Setup auto-completers $groupCompleter = { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) try { $map = _Get-GistMapData -ScriptRoot $PSScriptRoot if ($map) { $map.Keys | Where-Object { $_ -like "$wordToComplete*" } } } catch { } } $nameCompleter = { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) try { $map = _Get-GistMapData -ScriptRoot $PSScriptRoot if ($map) { $group = $fakeBoundParameters['Group'] if ($group -and $map.ContainsKey($group)) { $map[$group] | ForEach-Object { $_.name } | Where-Object { $_ -like "$wordToComplete*" } } } } catch { } } Register-ArgumentCompleter -CommandName Get-EndjinGist -ParameterName Group -ScriptBlock $groupCompleter Register-ArgumentCompleter -CommandName Get-EndjinGist -ParameterName Name -ScriptBlock $nameCompleter # export the non-private functions (by convention, private function scripts must begin with an '_' character) Export-ModuleMember -Function ( $functions | ForEach-Object { (Get-Item $_).BaseName } | Where-Object { -not $_.StartsWith("_") } ) ` -Alias @('gist', 'gists') |