Functions/Get-RepoInfo.ps1
function Get-RepoInfo { param( [string] [Parameter(Mandatory = $true, ValueFromPipeline = $true, HelpMessage = "The name of the repository that you wish to synchronize (e.g. Namespace/RepoName)")] $Repo, [string] [Parameter(HelpMessage = "The service hosting your repository (e.g. github.com)")] [ValidateSet("github.com", "dev.azure.com", "gitlab.com", "bitbucket.org")] $Service = "github.com", [string] [Parameter(HelpMessage = "The directory within which your repositories will be checked out (e.g. /src/)")] $Path = $GitTool.Directory ) $repoUrl = "https://$Service/$Repo" $gitUrl = "git@${Service}:$Repo.git" $repoPath = [System.IO.Path]::Combine($Path, $Service, $Repo.Replace('/', [System.IO.Path]::DirectorySeparatorChar)) if ($Service -eq "dev.azure.com") { $repoNameSplit = $Repo -split '/' $repoNamespace = $repoNameSplit[0..($repoNameSplit.Length - 2)] -join '/' $repoName = $repoNameSplit[-1] $repoUrl = "https://$Service/${repoNamespace}/_git/${repoName}" $gitUrl = "git@ssh.dev.azure.com:v3/$Repo" } return @{ Repo = $Repo; Service = $Service; Path = $repoPath; WebURL = $repoUrl; GitURL = $gitUrl; Exists = $(Test-Path -Path $repoPath -PathType Container); } } Register-ArgumentCompleter -CommandName Get-RepoInfo -ParameterName Repo -ScriptBlock $Function:SuggestRepoName |