Lib/get_naf_repo.psm1

<#
    .SYNOPSIS
        Get NAF Repo
 
    .DESCRIPTION
        Get NAF Repo
 
    .NOTES
        Author : hillesheim@n-dimensions.de
        Version : 1.7
        DateLastChanged : 2023-09-16
#>
 

Write-Host "Load module 'get_naf_repo' ... "; 

#region begin DECLARATION
    
    #region begin TYPES
    #endregion

    #region begin USER_VARIABLES

    [String] $gitLocalRepoFolder = "C:\_NAF"; 
    # [String] $gitAccessToken = "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";
        
    #endregion

    #region begin SYSTEM_VARIABLES

    [String] $gitRepoUrl = "https://github.com/lukashillesheim2/NAF"; 
    [String] $gitUserName = "lukashillesheim2"; 
    [String] $gitUserMail = "hillesheim@lh-itc.de"; 

    #endregion

#endregion

#region begin FUNCTIONS

Function Get-NafRepo {

    # Select job
    $enumJobSteps_GetNafRepo = "JobSteps_GetNafRepo" -as [System.Type]; 
    [JobSteps_GetNafRepo[]] $selection = `
    Enter-Selection `
            -Enum $enumJobSteps_GetNafRepo `
            -Default $defaultJobSteps_GetNafRepo `
            -Title "Job Steps: Please Select"
    Write-Host ("Selected job steps: "); 
    $selection `
        | ForEach-Object {
            Write-Host ("- {0}" -f $_); 
        }   

    # Open script editor
    If ($selection -contains [JobSteps_GetNafRepo]::OpenScriptEditor) {
        Open-ScriptEditor `
            -Filepath $psScriptFilePath 
    }

    # Device auth
    If ($selection -contains [JobSteps_GetNafRepo]::GhSetDeviceAuth) {
        Write-Host ("The local device is to be authenticated by github client ... "); 
        gh auth login --git-protocol https --web; 
        # gh auth login;
    }
    
    # Set git config
    If ($selection -contains [JobSteps_GetNafRepo]::SetGitConfig) {
        Write-Host ("Set git configuration ... "); 
        Write-Host ("- User name: {0} " -f $gitUserName); 
        Write-Host ("- Mail: {0} " -f $gitUserMail); 
        
        git config --global user.name $gitUserName; 
        git config --global user.email $gitUserMail; 
    }

    # Clone repository
    If ($selection -contains [JobSteps_GetNafRepo]::GhCloneRepository) {
        Write-Host ("Clone repository ... "); 
        # .\git.exe clone $gitRepoUrl $gitLocalRepoFolder;
        gh gist clone $gitRepoUrl $gitLocalRepoFolder; 
    }

    # Abort
    If($selection -contains [JobSteps_GetNafRepo]::Abort) {
        Return; 
    }

    # Run another job
    $userInput = Read-Host("Run another job (y|n)? Press ENTER for 'y'"); 
    If("" -eq $userInput ){
        Main; 
    }
    
}

#endregion