I wanted to reproduce it in C#. I’ve previously created to modernized Process library — ProcessX — Simplify call an external process with async streams in C# 8.0.
C#’s top level statement, async/await extensibility and static using are perfect as an internal DSL and is able to provide simplicity comparable to zx.
These are already available in ProcessX (v1.4.2), so you can install them with NuGet and try them out right away!
The advantage over bash/cmd/PowerShell is
- Static typed
- Code formatter
- Clean syntax via C#
- Powerful editor environment(Visual Studio/Code/Rider)
There are many advantages and strengths of being in C#.
Scripts can be managed in csx(C# Script) or csproj and single cs files. csx seems ideal, but the execution and editing environment is poor, so a csproj base would be better. By running csproj with dotnet run, directly launches the shell script without pre build.
Proposed evolution of C# Scripting is discussed at https://github.com/dotnet/designs/pull/213 . proposed/simple-csharp-programs.md is interesting note, however, it will be a long time before it is realized.
If you want to manage multiple scripts, please try my ConsoleAppFramework library. It allows multiple command line scripts to live together by simply defining classes and methods.
This allows you to manage multiple shell scripts with a single csproj (you can separate them by invoking dotnet run — target/method).