Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# -------- GO getLastLogsOnly for Shtivi's RDR2 mods --------
- 1.1 : Contracts + curDate dans le filename
- 1.2 : OK pour Bounties, BUGS : filename est juste ".log"
- 1.3 : retour au dir ou le script a ete lance
- 1.4.0 : [WIP] Ajoute params
- 1.4.1 : supprime $input_targetModDirPath inutile
- 1.4.2 : variabilise args0
- 1.4.3 : list allowed params OK
- 1.5.0 : PEC allowed params list true
- 1.5.1.0 : remplace $input_targetModDirPath par input_targetDirPath BUG : isAllowed ne marche pu (OK FIX)
- ---------- WIP [OK]
- 1.5.1.1 : messageerreur si !allowedparam
- 1.5.1.2 : BUG : rien ne marche sauf input vide, FIX : BUG : maintenant tout passe
- 1.5.1.3 : essaye de fix le BUG maintenant tout passe (BUG : input dir : rrr allowed : True) SAUF VOID
- 1.5.1.4 : essaye de fix le BUG maintenant tout passe (BUG : input dir : rrr allowed : True) SAUF VOID
- ---> FIX ERROR toujours TRUE sauf VOID : $input_params = $args : $paramIsAllowed = $input_modName -in $input_params ----> $paramIsAllowed = $input_modName -in $allowedParams
- + renomme $input_targetModDirPath en input_modName (SAUF ou c'est effectivement un PATH)
- + ajoute USAGE : <nom du script + nouvelle function getCurrentScriptFilename(){ return Split-Path $PSCommandPath -Leaf }
- BUG : Get-content : Cannot find path 'D:\SCRIPTS_TRUCS\POWERSHELL\RDR2\Log.log' because it does not exist.
- At D:\SCRIPTS_TRUCS\POWERSHELL\RDR2\script_getLastLogsOnly_1.5.1.4.ps1:191 char:1
- + Get-content -tail $latestLogLinesLength .\Log.log > $outputFilename
- ---> NEED fullpath du fichier de Log.log
- <# ========================================== ___ ___ _ _ ___ _____ ___ ___ _ _ ___ ========================================== #>
- <# ========================================== | __| / _ \ | \| | / __| |_ _| |_ _| / _ \ | \| | / __| ========================================== #>
- <# ========================================== | _| | (_) | | .` | | (__ | | | | | (_) | | .` | \__ \ ================small===================== #>
- <# ========================================== |_| \___/ |_|\_| \___| |_| |___| \___/ |_|\_| |___/ ========================================== #>
- <# ========================================== ========================================== #>
- function getCurrentScriptFilename(){
- return Split-Path $PSCommandPath -Leaf
- }
- <# ========================================== ___ _ _ ___ _____ ========================================== #>
- <# ========================================== |_ _| | \| | |_ _| |_ _| ========================================== #>
- <# ========================================== | | | .` | | | | | ====small================================= #>
- <# ========================================== |___| |_|\_| |___| |_| ========================================== #>
- <# ========================================== ========================================== #>
- $currentScriptName = Split-Path $PSCommandPath -Leaf
- Write-Host "Executing script :" $currentScriptName
- $currentScriptName2 = getCurrentScriptFilename
- Write-Host "Executing script :$currentScriptName2"
- # $currentScriptName3 = $MyInvocation.ScriptName -Leaf
- # Write-Host "Executing script : $currentScriptName3"
- # $currentScriptName3 = $MyInvocation.MyCommand.Name
- # Write-Host "Executing script : $currentScriptName4"
- Write-Host "[1]SCRIPT = " $currentScriptName -back black
- Write-Host [2]SCRIPT =" $currentScriptName" -back black
- Write-Host [3]SCRIPT ="$currentScriptName" -back black
- Write-Host [4]SCRIPT ="$currentScriptName" -back black
- Write-Host "[5]SCRIPT=$currentScriptName" -back black
- $baseDir = get-location
- $input_params = $args
- $nb_inputParams = $args.Length
- $input_modName = $args[0]
- $allowedParams=@(
- $void
- , "bounties"
- , "b"
- , "contracts"
- , "c"
- , "stagecoaches"
- , "s"
- )
- Write-Host " ------- "
- Write-Host " $nb_inputParams params inputted : " -no
- Write-Host $input_params
- if($nb_inputParams -gt 1){
- Write-Host -fore DarkRed "Input error : max 1 param accepted"
- # Write-Host -fore DarkGreen "USAGE : ./script_getLastLogsOnly_X.Y.ps1 [param]"
- Write-Host -fore DarkGreen "USAGE : .\$currentScriptName [option]"
- break
- }
- Write-Host "PARAM 1:"$input_modName
- Write-Host "Liste params PEC :"$allowedParams
- $paramIsAllowed = $input_modName -in $allowedParams
- Write-Host "Input param '"$input_modName"'"
- if($paramIsAllowed){
- Write-Host "Param '"$input_modName"' allowed ? (= in allowed params list) : " $paramIsAllowed -fore green
- }
- else{
- Write-Host "Param '"$input_modName"' allowed ? (= in allowed params list) : " $paramIsAllowed -fore red
- }
- # Write-Host "input dir : " $input_modName allowed " : " -fore Yellow -no
- # write-host -fore Red $paramIsAllowed
- # $input_modName = ""
- # if($input_params.Length -gt 1){
- # Write-Host -fore red "Too many params, just 1 allowed."
- # Write-Host -fore Green "USAGE : ./script_getLastLogsOnly_X.Y.ps1 [param]"
- # break
- # } elseif ($paramIsAllowed){
- # fais rien, j'ai pas reussi a faire une negation if false
- # } else { <# $param Is NOT allowed #>
- # Write-host -fore red "Invalid param : " $input_modName Write-Host -fore Yellow "Accepted parameters : " -no
- # foreach ($okParam in $allowedParams){ if($okParam.Length -eq 0){ Write-Host -fore Yellow `n " - <VOID> `t`t [DEFAULT ---> Bounties dir] `t`t (0)" -no
- # } else{ Write-Host -fore Yellow `n " - " $okParam `t`t "("$okParam.Length")" -no }
- # }
- # break
- # }
- <# ========================================== ___ ___ ___ ___ ___ _____ ========================================== #>
- <# ========================================== / __| / __| | _ \ |_ _| | _ \ |_ _| ==small=================================== #>
- <# ========================================== \__ \ | (__ | / | | | _/ | | ========================================== #>
- <# ========================================== |___/ \___| |_|_\ |___| |_| |_| ========================================== #>
- <# ========================================== ========================================== #>
- if($input_modName.Length -eq 0 -or $input_modName -eq "bounty"){
- $input_targetModDirPath = "C:\Program Files (x86)\Steam\steamapps\common\Red Dead Redemption 2\BountiesExpansion"
- }
- write-Host "taget dir = '"$input_targetModDirPath "'"
- cd $input_targetModDirPath
- $content = (get-content "Log.log")
- $totalNbLignes = $index = $content.Count
- $latestLogLinesLength = 0
- $logfileDir = Split-Path -Path (Get-Location) -Leaf
- $curDate = Get-Date -Format "yyyyMMdd"
- $outputFilename = $logfileDir + "_" + $curDate + "_lastLog.log"
- Write-Host "filename = $outputFilename"
- while($index--){
- if($content[$index] -match "^.*Shtivi.*$"){
- break
- }
- }
- $latestLogLinesLength = $totalNbLignes - $index
- Get-content -tail $latestLogLinesLength .\Log.log > $outputFilename
- Start notepad++ $outputFilename
- cd $baseDir
- <# -------- END -------- #>
- <# meeeeh #>
- <# $verbose=false #>
- <# if($verbose) { Write-Host -fore Cyan "index = $index" -nonewline } #>
- <# if($verbose){ Write-Host [$index] -Nonewline } #>
- <# if($verbose){ Write-Host -foregroundColor Yellow "[$index]" } #>
- <# if($verbose) { Write-Host "wewewew" -Nonewline } #>
- <# Write-Host -fore red "Le dernier log commence ligne [$index] et s arrete a [$totalNbLignes]" #>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement