Functions/Get-HgConfig.ps1


function Get-HgConfig
{
    <#
    .SYNOPSIS
    Gets the value for a given Mercurial configuration option.
     
    .DESCRIPTION
     
    ALIASES
      ghgcfg
     
    .EXAMPLE
    Get-HgConfig -Name 'ui.username'
     
    Returns the value of the `ui.username` setting.
    #>

    [CmdletBinding()]
    param(
        [string]
        # The name of the setting to get. If not given, returns all settings.
        $Name,
        
        [string]
        # The path to the repository whose configuration to retrieve.
        $RepoRoot = (Get-Location)
    )
    
    $repoArgName = ''
    $repoArgValue = ''
    if( $RepoRoot )
    {
        $repoArgName = '-R'
        $repoArgValue = Resolve-HgRoot -Path $RepoRoot
    }
    
    hg showconfig $Name $repoArgName $repoArgValue
}

Set-Alias -Name 'hgshowconfig' -Value 'Get-HgConfig'
Set-Alias -Name 'ghgcfg' -Value 'Get-HgConfig'