Lib/get_repo.psm1
<#
.SYNOPSIS Get NAF Repo .DESCRIPTION Get NAF Repo .NOTES Author : hillesheim@n-dimensions.de Version : 1.7 DateLastChanged : 2023-09-16 #> Using Module .\helper.psm1; Write-Host "Load nested module 'git_repo' ... "; #region DECLARATION #region TYPES #endregion #region VARIABLES_USER [String] $gitLocalRepoFolder = "C:\_NAF"; # [String] $gitAccessToken = "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"; #endregion #region VARIABLES_SYSTEM [String] $gitRepoUrl = "https://github.com/lukashillesheim2/NAF"; [String] $gitUserName = "lukashillesheim2"; [String] $gitUserMail = "hillesheim@lh-itc.de"; [String] $psScriptFilePath = $MyInvocation.MyCommand.Definition; [String] $psScriptFolderPath = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent; #endregion #endregion #region FUNCTIONS_PUBLIC Function Get-NafRepo { # Select job $enumJobSteps_GetRepo = "JobSteps_GetRepo" -as [System.Type]; [JobSteps_GetRepo[]] $selection = ` Show-EnumSelection ` -Enum $enumJobSteps_GetRepo ` -Default $defaultJobSteps_GetRepo ` -Title "Job Steps: Please Select" Write-Host ("Selected job steps: "); $selection ` | ForEach-Object { Write-Host ("- {0}" -f $_); } # Open script editor If ($selection -contains [JobSteps_GetRepo]::OpenScriptEditor) { Open-ScriptEditor ` -Filepath $psScriptFilePath } # Device auth If ($selection -contains [JobSteps_GetRepo]::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_GetRepo]::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_GetRepo]::GhCloneRepository) { Write-Host ("Clone repository ... "); # .\git.exe clone $gitRepoUrl $gitLocalRepoFolder; gh gist clone $gitRepoUrl $gitLocalRepoFolder; } # Abort If($selection -contains [JobSteps_GetRepo]::Abort) { Return; } # Run another job $userInput = Read-Host("Run another job (y|n)? Press ENTER for 'y'"); If("" -eq $userInput ){ Get-NafRepo; } } #endregion #region FUNCTIONS_PRIVATE #endregion #region EXPORT Export-ModuleMember -Function 'Get-NafRepo' #endregion |