{"id":15064065,"url":"https://github.com/digao-dalpiaz/digaorunner","last_synced_at":"2026-01-03T03:37:19.775Z","repository":{"id":254761304,"uuid":"847463980","full_name":"digao-dalpiaz/DigaoRunner","owner":"digao-dalpiaz","description":"Run scripts locally and remotely","archived":false,"fork":false,"pushed_at":"2024-10-26T20:57:33.000Z","size":565,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T09:28:03.622Z","etag":null,"topics":["cmd","command-line","copy-files","deploy","pipeline","powershell","prompt","script","zip-files"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digao-dalpiaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-25T22:19:03.000Z","updated_at":"2024-10-26T20:57:36.000Z","dependencies_parsed_at":"2024-08-25T23:58:38.707Z","dependency_job_id":"780027a3-5583-4258-8342-212be48f7ba2","html_url":"https://github.com/digao-dalpiaz/DigaoRunner","commit_stats":null,"previous_names":["digao-dalpiaz/digaorunner"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digao-dalpiaz%2FDigaoRunner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digao-dalpiaz%2FDigaoRunner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digao-dalpiaz%2FDigaoRunner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digao-dalpiaz%2FDigaoRunner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digao-dalpiaz","download_url":"https://codeload.github.com/digao-dalpiaz/DigaoRunner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243786231,"owners_count":20347603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmd","command-line","copy-files","deploy","pipeline","powershell","prompt","script","zip-files"],"created_at":"2024-09-25T00:10:57.550Z","updated_at":"2026-01-03T03:37:19.728Z","avatar_url":"https://github.com/digao-dalpiaz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DigaoRunner\n\n## Run scripts locally and remotely\n\n![Preview](images/preview_script_run.png)\n\nIn my work environment, I frequently need to create scripts to automate processes. Whether it's to copy files from one place to another for deploying an application or even for more complex tasks involving multiple steps, such as installing services, configuring Windows settings, reading files and extracting information, or any other activity that can be automated.\n\nThese are typically tasks where it's not worth writing a specific program. In such cases, we usually resort to a **Batch script (.BAT or .CMD)** or the more modern **PowerShell**.\n\nBut let's be honest, for any of these scripts, the language is not very practical, and the script ends up being hard to read and understand, and it's not efficient. For example, error handling in these scripts is cumbersome, and typically, the processes continue even if an error occurs in the middle of the script.\n\nWith all this in mind, I developed Digao Runner, which is essentially a debugger for scripts with the **.ds (Digao Script)** extension, where you can write the script using **C# code** in a very practical and easy way. The code is very clean, has **exception handling**, and you can also configure **input fields** for the user to fill in at runtime, like parameters or variables of the script.\n\nHere is an example of a Digao Runner script, used specifically to create the package for the program itself:\n\n```csharp\n@DIGAOSCRIPT\nVERSION=1\nTITLE=Create Digao Runner Package\n\n@CODE\nEcho(\"========================================================\", Color.Cyan);\nEcho(\"Generate Digao Runner zip package\", Color.Cyan);\nEcho(\"========================================================\", Color.Cyan);\n\nint ret;\n\nstring vsWhere = @\"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe\";\nstring sevenZip = @\"C:\\Program Files\\7-zip\\7z.exe\";\nstring pathProject = @\".\\DigaoRunnerApp\\DigaoRunnerApp.csproj\";\nstring tmpBuildDir = @\".\\Temp_Build\";\nstring packageFile = @\".\\DigaoRunner.zip\";\n\nstring vsPath;\nret = RunProcessReadOutput(vsWhere, \"/latest /property installationPath\", ref vsPath);\nif (ret != 0) Abort(\"Error getting Visual Studio installation path\");\n\nvsPath = vsPath.Split(Environment.NewLine).FirstOrDefault();\nif (string.IsNullOrEmpty(vsPath)) Abort(\"Visual Studio path empty\");\n\nstring msBuildExe = Path.Combine(vsPath, @\"MSBuild\\Current\\bin\\msbuild.exe\");\n\nif (Directory.Exists(tmpBuildDir)) Directory.Delete(tmpBuildDir, true);\nif (File.Exists(packageFile)) File.Delete(packageFile);\n\nEcho(\"Compile project\");\nret = RunProcess(msBuildExe, \n\t$\"\\\"{pathProject}\\\" /clp:ErrorsOnly /t:Rebuild /p:PlatformTarget=x64 /p:Configuration=Release /p:OutputPath=\\\"{Path.GetFullPath(tmpBuildDir)}\\\"\");\n//using GetFullPath because MSBUILD internally uses current path as project folder path\n\t\nif (ret != 0) Abort(\"Error compiling project\");\n\nEcho(\"Create zip file\");\n//RunProcess(sevenZip, $\"a -sfx DigaoRunnerSetup.exe \\\"{tmpBuildDir}\\\"\");\nZipFile.CreateFromDirectory(tmpBuildDir, packageFile);\n\nDirectory.Delete(tmpBuildDir, true);\n\nEcho(\"Package successfully created!\", Color.Yellow);\n\n```\n\n# Installation\n\n1. Download and install [.NET 8 Desktop Runtime x64](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)\n\n2. Download last Digao Runner release (.zip) from [here](https://github.com/digao-dalpiaz/DigaoRunner/releases/latest)\n\n3. Extract zip to a folder in your computer (Example: C:\\DigaoRunner)\n\n4. You may open DigaoRunnerApp.exe and go to menu \"More\" \u003e \"Register .ds files\", so the scripts will automatically run with this program.\n\nYou are set. Enjoy!\n\n# Script file structure\n\nTo create scripts, use the following structure in the file with the .ds extension:\n\n```csharp\n@DIGAOSCRIPT\n\nVAR1=value\nVAR2=value\nVAR3=value\n\n$FIELD1={...}\n$FIELD2={...}\n$FIELD3={...}\n\n@CODE\nYour code here in C# format\n```\n\n## Header section\n\nThe header section is the part after `@DIGAOSCRIPT` identifier, and before `@CODE` section. In this part, you can specify variable and fields.\n\n### Header Variables\n\n- `VERSION=1` (required)\n- `TITLE=Your script title` (optional) it will appear in the window title\n- `ADMIN=true` (optional) if specified, it will request Administrator elevation when running the script\n- `$MY_FIELD={...}` (optional) it will show the field input when running script, before executing code section\n\n**If any field is specified (using prefix `$`), then when the script is run, the user will first be prompted to fill in the fields.**\n\nComments are allowed in header section using `//` prefix\n\n### Header Fields\n\nThe fields have the following structure in JSON format:\n\n`$MY_FIELD={\"Label\": \"Field Description\", \"Type\": \"...\", \"Default\": ..., \"Items\": [], Editable: true}`\n\n`Type` property values:\n- \"text\" (TextBox)\n- \"check\" (CheckBox)\n- \"combo\" (ComboBox)\n\n`Default` property is optional and must be according to the `Type`. Example: When `Type` = `text`, default value must be string (`\"default value\"`). When `Type` = `check`, default value must be boolean (`true` or `false`).\n\n`Items` property is a string array and should be specified when `Type` = `combo`. Example: `[\"VALUE1\", \"VALUE2\", \"VALUE3\"]`.\n\n`Editable` property is optional and allows configure an editable Combo Box.\n\n![Fields](images/preview_fields.png)\n\n## Code Tricks\n\nThe following imports are internally specified:\n- System\n- System.Text\n- System.Linq\n- System.IO\n- System.IO.Compression\n- System.Diagnostics\n- System.Drawing\n- System.Text.RegularExpressions\n- Microsoft.Win32\n\nSo, you may use classes from these imports directly. Example: `StringBuilder` (comes from System.Text).\n\nUse Abort method to interrupt execution with a message.\n```csharp\nvoid Abort(string message);\n```\n\nUse GetField method to get a field value.\n```csharp\nobject GetField(string name);\nT GetField\u003cT\u003e(string name);\n```\n\nUse Echo method to print a message line in the console.\n```csharp\nvoid Echo(string text = null, Color? color = null);\n```\n\nUse Sleep method to wait for specified miliseconds.\n```csharp\nvoid Sleep(int ms);\n```\n\nUse CheckStop method if you want to check if cancel was requested during some code execution.\n```csharp\nvoid CheckStop();\n```\n\nUse CopyFile method if you want to copy a file with progress bar\n```csharp\nvoid CopyFile(string sourceFilePath, string destinationFilePath);\n```\n\nUse SetSystemConsoleEncoding method before run a process to ensure local system encoding.\n```csharp\nvoid SetSystemConsoleEncoding();\n```\n\nUse RunProcess method to run an external process and monitoring output lines in console.\nThe returning is the process Exit Code. There is a variable `LastExitCode` available too.\n```csharp\nint RunProcess(string fileName, string arguments);\n```\n\nUse RunProcessReadOutput method to run an external process and get the output lines in a string variable (the output lines will not be automatically printed in the console).\nThe returning is the process Exit Code. There is a variable `LastExitCode` available too.\n```csharp\nint RunProcessReadOutput(string fileName, string arguments, ref string output);\n```\n\n# Running scripts remotely\n\nTo run scripts remotely, you can use an SSH connection. The [SSH.NET Library](https://github.com/sshnet/SSH.NET) can be used for SSH and SFTP connection (file transfer).\n\nSSH and SFTP connection example:\n\n```csharp\n@DIGAOSCRIPT\nVERSION=1\nTITLE=SSH and SFTP example\n\n@CODE\nusing Renci.SshNet;\nusing Renci.SshNet.Common;\n\nusing (var ssh = new SshClient(\"myhost.com\", 22, \"user\", \"password\")) \n{\n\tvar command = ssh.RunCommand(\"ping 127.0.0.1 -c 6\");\n\tEcho(command.Result);\n}\n\nusing (var sftp = new SftpClient(\"myhost.com\", 22, \"user\", \"password\"))\n{\n\tsftp.WriteAllText(\"/home/file1.txt\", \"Some file text\");\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigao-dalpiaz%2Fdigaorunner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigao-dalpiaz%2Fdigaorunner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigao-dalpiaz%2Fdigaorunner/lists"}