Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Funciona para PowerShell Versiones >=5.2
- function Get-Plantilla{
- ## Descarga una plantilla de pasterbin.com
- ## @Param type : Tipo de plantilla (html, c, c++, servidor simple python)
- ## @Param name_file : Nombre con el que se guardara el archivo.
- ## @Return name_file
- # @TODO: Hacer el equivalente en python.
- param(
- [String]$type,
- [String]$name_file
- );
- $recomende_lang="html, c, c++";
- $pls="server";
- if ($type -eq ""){
- Write-Error -Message "Error no se paso el tipo de plantilla." -ErrorId "-1" -RecommendedAction ("Se recomienda inglesar estos lenguajes: "+$recomende_lang+" o estas plantillas "+$pls)
- return -1;
- }
- $name_output=if ($name_file -eq ""){"main.$type"}else{$name_file};
- $url_from_plantilla="https://pastebin.com/raw/igR2QKnH";
- switch($type){
- "html"{
- $url_from_plantilla="https://pastebin.com/raw/igR2QKnH";
- $name_output=if ($name_file -eq ""){"html.$type"}else{$name_file};
- }
- "c"{
- $url_from_plantilla="https://pastebin.com/raw/1U5xQByG";
- }
- "c++"{
- $url_from_plantilla="https://pastebin.com/raw/04Rwptuc";
- $name_output=if ($name_file -eq ""){"main.cpp"}else{$name_file}
- }
- "server"{
- $url_from_plantilla="https://pastebin.com/raw/PUt1pUW3";
- $name_output=if ($name_file -eq ""){"sserver.py"}else{$name_file}
- }default{
- Write-Error -Message "Error no se reconose el lenguaje deseado" -ErrorId "-2" -RecommendedAction ("solo se reconocen los siguientes lenguajes: "+$recomende_lang)
- return -2;
- }
- }
- echo "Descargando plantilla de $url_from_plantilla ..."
- Invoke-WebRequest $url_from_plantilla -OutFile $name_output
- echo "La descarga de la plantilla $type fue un exito:)"
- echo "El nombre del archivo es:"
- return $name_output
- }r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement