Console and CLI Applications
Features: exit codes (Function Main As Integer), stdin/stdout piping (Console.In.ReadToEnd()), Console.CancelKeyPress for Ctrl+C, colors and cursor control, progress bars (Spectre.Console, ShellProgressBar), interactive prompts, the Generic Host for DI/config (Module 30).
Distribute as a single-file executable or as a .NET tool (<PackAsTool>true</PackAsTool> → dotnet tool install -g).
Imports System.CommandLine ' NuGet: System.CommandLine (API evolving; check your version)
Module Program
Function Main(args As String()) As Integer
Dim fileArg As New Argument(Of IO.FileInfo)("file", "CSV file to import")
Dim dryRun As New [Option](Of Boolean)("--dry-run", "Validate without saving")
Dim root As New RootCommand("Shop import tool") From {fileArg, dryRun}
root.SetHandler(Sub(file As IO.FileInfo, dry As Boolean) Import(file, dry), fileArg, dryRun)
Return root.Invoke(args)
End Function
Sub Import(file As IO.FileInfo, dry As Boolean)
Console.ForegroundColor = ConsoleColor.Cyan
Console.WriteLine($"Importing {file.FullName} (dry run: {dry})")
Console.ResetColor()
End Sub
End Module