I want to write a couple of commands for the NuGet Package Manager console to insert the βGistsβ from GitHub . I have 4 main teams
- List-Gists 'user'
- Gist-info 'gistId'
- Gist-Contents 'gistId' 'fileName'
- Gist-Insert 'gistId' 'fileName'
All my teams depend on a couple of utility functions, and I struggle with whether they need to be global or not.
# Json Parser function parseJson([string]$json, [bool]$throwError = $true) { try { $result = $serializer.DeserializeObject( $json ); return $result; } catch { if($throwError) { throw "ERROR: Parsing Error"} else { return $null } } } function downloadString([string]$stringUrl) { try { return $webClient.DownloadString($stringUrl) } catch { throw "ERROR: Problem downloading from $stringUrl" } } function parseUrl([string]$url) { return parseJson(downloadString($url)); }
Can I just use these utility functions outside my global functions, or do I need to somehow include them in each area of ββthe definition of global functions?
Jacob source share