Get started with Runic Command Line

On this page

Runic Command Line turns typed C# methods into commands with help, validation and human or JSON output. This page takes you from an empty folder to a working command.

It covers release 0.15.0. Every link to the Command Line repository points at that release, so the code matches the packages you install.

What it is #

Runic Command Line is a command framework for .NET 10 that works with NativeAOT. You write a static method and mark it with [Command]. A source generator, which ships inside the core package, reads those methods at build time and creates a command catalog, GeneratedCommandCatalog. CommandApp runs that catalog: it parses the arguments, shows help and the version, executes the command and maps the outcome to an exit code. There is no runtime reflection, so the result can be published as a small native executable.

The library does not depend on a UI framework, a Generic Host or a particular parser. Presentation with Spectre.Console is an optional package.

Packages #

All packages release together. Keep the optional packages on exactly the same version as the core package.

Package Purpose
Runic.CommandLine Commands, parsing, execution, hosting and output. Includes the generator.
Runic.CommandLine.Spectre Optional Spectre.Console presentation: styled help, tables, progress, prompts.
Runic.CommandLine.Processes Optional bounded execution of local child processes.
Runic.CommandLine.Testing Optional in-memory test helpers, such as CommandAppTester.

Your first command #

Create a console project and add the core package:

dotnet new console --framework net10.0 --name HelloCli
cd HelloCli
dotnet add package Runic.CommandLine --version 0.15.0

Replace Program.cs with this program. It is the maintained hello-world/Program.cs example:

using Runic.CommandLine;
using Runic.CommandLine.Generated;

return await new CommandApp(GeneratedCommandCatalog.Create()) { Name = "hello" }.RunAsync(args);

internal static class Commands
{
    [Command("greet", Description = "Say hello."), DefaultCommand]
    internal static string Greet([Argument] string name = "world",
        [Option("--count", "-n", Minimum = 1, Maximum = 100)] int count = 1) =>
        string.Join('\n', Enumerable.Repeat($"Hello, {name}!", count));
}

The parts you need to know:

  • [Command("greet")] makes the method a command. A name with a space, such as "config show", creates a command group automatically.
  • [DefaultCommand] runs greet when no command name is given, so hello Ada and hello greet Ada do the same.
  • [Argument] is a positional value; [Option("--count", "-n")] is a named option with an alias. A C# default makes it optional. A non-nullable option without a default is required.
  • Minimum and Maximum are checked before the method runs.
  • The method's return value is the result. string, void, Task and ValueTask need no extra setup. An int result is data, not an exit code.

A method can also take a CancellationToken, a CommandExecutionContext or an ICommandConsole; they are passed in automatically. Other services use [FromServices].

Build and run #

dotnet run -- Ada --count 2
dotnet run -- Ada --count 2 --format=json
dotnet run -- --help

The first command prints Hello, Ada! twice. The second prints one JSON response instead; see Output for people and for scripts.

To ship a native executable, publish with NativeAOT for your platform, as the release's package check does:

dotnet publish -c Release -r linux-x64 -p:PublishAot=true

Since 0.9.0, NativeAOT applications are supported on linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64, win-x64, win-arm64 and osx-arm64; the release's CI publishes and runs them on each of these, the musl RIDs in Alpine.

Help and validation #

CommandApp builds help from the catalog. hello --help, hello help greet and hello greet --help all work, and hello --version prints CommandApp.Version. Only root help lists --version (since 0.15.0). Set Description on commands, arguments and options to fill the help text.

Input is checked in two places:

  • At build time. The generator reports RCLI9xxx compiler errors for a [Command] method it cannot use, for example a parameter without [Argument], [Option] or [FromServices]. The command is skipped until you fix the error. Each ID is explained in source generator diagnostics.
  • At run time. Unknown options, missing required values, values outside Minimum/Maximum, Choices, MustExist paths and Requires or ConflictsWith rules fail before the method runs. The error names the parameter but never echoes its value. Close typos get suggestions.

Since 0.10.0, human output writes each diagnostic as its message without the leading code, and a usage error (exit code 2) ends with the command's usage line and the help command to run:

The <binding> argument is missing.
Usage: storyline bind <world> <binding> [options]
Run "storyline bind --help" for more information.

Since 0.11.0, human output keeps the line breaks of a fault or diagnostic message, so a message such as 2 problems in saltmarch:\n codex/a.md: bad prints on two lines instead of one; JSON output still keeps each message on one line. An old script's --output json is still the usage error RCLI1001, but its message suggests the selector: Did you mean '--format'?. An application whose commands have their own --format option moves the selector with [assembly: OutputSelector("--output-format")].

Positional arguments bind left to right, so RCLI1005 missing-argument names the first argument the given tokens do not reach, by its placeholder as the usage line shows it (since 0.13.0). JSON output keeps every code, kind, message key and argument and never contains the usage lines; a diagnostic that names one argument or option also carries its ID as binding. Compare it, or a diagnostic's Code, Kind, Arguments and Binding, in tests rather than the English text.

Shared options and environment variables #

An option can fall back to an environment variable. An explicit argument wins over the environment, which wins over the C# default. This command comes from the release's command tree example:

[Command("config show", Description = "Show the chosen environment.")]
internal static string Config([Option("--environment", EnvironmentVariable = "HELLO_ENV", Choices = ["local", "production"])] string environment = "local") => environment;

An option that every command accepts, such as --verbose, is added to the catalog with GlobalOption. It may appear before or after the command name:

GeneratedCommandCatalog.Create(builder => builder
    .GlobalOption("verbose", "--verbose", CommandArity.Zero, new CommandHelp("Show detailed progress."), "-v"))

Response files #

Since 0.9.0, an application whose command lines grow long can read arguments from response files. It is off unless the catalog declares it, because an argument may legitimately start with @:

GeneratedCommandCatalog.Create(builder => builder.ResponseFiles())

hello @greet.rsp then runs as if the arguments in greet.rsp had been given in its place. A response file is UTF-8, with or without a byte order mark. Lines whose first non-blank character is # are comments, arguments are quoted as on the Windows command line, @file inside a response file is relative to that file's directory, files nest at most 16 levels deep, and @@ stands for a literal leading @. In PowerShell, quote the argument (hello '@greet.rsp'). A file that cannot be used is a usage error, exit code 2: RCLI1017 (cannot be read), RCLI1018 (not valid UTF-8), RCLI1019 (unterminated quote), RCLI1020 (nested too deeply) or RCLI1021 (includes itself). Help lists @<file>, and the generated completions complete a file name after @. CommandLineHostingAdapter.Classify expands the files too. See read arguments from response files.

Output for people and for scripts #

By default a command writes human text. --format json, or the environment variable RUNIC_COMMANDLINE_OUTPUT=json, switches to machine output: exactly one JSON response on stdout, with the protocol runic.commandline/1. It holds success, exitCode, the typed payload on success and a fault on failure. In JSON mode the injected ICommandConsole sends other output, such as progress, to stderr, so stdout stays parseable.

Results other than strings declare a payload identity and a source-generated JSON context with [CommandResult("example.result/1", typeof(JsonContext))]. Give that context camelCase property names, for example with [JsonSourceGenerationOptions(JsonSerializerDefaults.Web)]; otherwise the generator warns with RCLI9044, because the payload would keep the C# property names inside the camelCase envelope. The protocol specification describes every field.

builder.Present<T>(path, …) changes the human output of a command's result. Since 0.9.0, builder.PresentOutcome<T>(path, presenter) owns a command's whole human output, failures included: the presenter receives the outcome, the exit code, the diagnostics, the command and the invocation's context, and WriteDefaultAsync writes what the outcome sink would have written. It runs only in human mode; JSON output is unchanged. Register presenters instead of a custom ICommandOutcomeSink that only changes some commands' human output. The context that a sink or a presenter receives now carries the handler's state, such as its TextResolver and RUNIC_COMMANDLINE_NO_INPUT, instead of fresh defaults.

In tests, CommandTestEnvelope.Read<T>(json, expectedPayloadType, typeInfo) from Runic.CommandLine.Testing, new in 0.9.0, reads a captured JSON response as strictly as CommandJsonEnvelopeReader.Read<T>, also rejects members the protocol does not define, and returns the typed CommandResponse<T>. CommandTestEnvelope.Parse checks the framing only.

Exit codes #

A command's outcome has a category, CommandExitCategory, and each category has a default exit code in CommandExitCodes. The defaults below come from that type and the protocol specification:

Exit code Category Meaning
0 Success The command succeeded.
1 CommandFailure The command reported an expected failure.
1 Unavailable A required resource or service was missing.
2 Usage The arguments could not be parsed.
2 Validation The input has the wrong shape.
3 HostFailure The host or framework failed unexpectedly.
130 Cancelled The command was cancelled, for example Ctrl+C.

Validation is for input a handler rejects because of its shape, whatever the state the command works on, such as two options that exclude each other or --since later than --until. A domain failure on well-formed input (a business rule refused the operation, a check found problems) is CommandFailure, and a missing resource Unavailable; both exit 1. Since 0.11.0 the documentation states this mapping, so scripts can tell "fix the command line" (2) from "the operation failed" (1). The codes themselves did not change.

These are the exit codes of every Runic tool. Categories that share a code are still distinct in CommandExitCategory, the JSON fault and observers. CommandApp.HandleTerminationSignals (on by default) handles Ctrl+C, SIGTERM and SIGQUIT: the first signal cancels the command. A repeated signal while the command still runs ends the process at once with 128 plus the signal number: 130, 143 or 131. Cleanup that must finish can call CommandExecutionContext.ProtectShutdown() to keep a repeated signal from exiting until the scope is disposed. Set CommandApp.ExitCodePolicy to map categories to other nonzero codes.

Command Line 0.8.0 changed these codes and renamed the output selector from --output to --format; a catalog keeps the old spelling as a hidden alias with OutputSelector("--format", "--output"). See the 0.8.0 upgrade table.

Styled output with Spectre #

Add Runic.CommandLine.Spectre at the same version, then set the console and help presenter. The parsing and the JSON output stay the same:

return await new CommandApp(GeneratedCommandCatalog.Create())
{
    Name = "hello",
    Console = new SpectreCommandConsole(),
    HelpPresenter = new SpectreHelpPresenter()
}.RunAsync(args);

Colors are turned off for redirected output, NO_COLOR and TERM=dumb.

Commands next to an existing application #

An application that already owns its startup, services and UI can run the same generated commands with CommandLineHostingAdapter. It decides whether the arguments ask for a command, help or the UI, and runs a command in a service scope that your application supplies. When the first word is a close match for a visible command, such as lst for list, the launch still opens the UI, and decision.SuggestedCommand names the command. Call adapter.WriteSuggestionAsync(decision) before opening the UI to write the standalone "Did you mean 'list'?" line to standard error. This is new in 0.6.0-preview.5. The hosted example shows the full flow, and adding a CLI to a WPF application applies it to a desktop app.

A Runic Desktop host must start on the main thread before any await, so a command such as my-app ui hands its start back to Main with ContinueOnCallingThread, and Main returns CommandApp.Run(args), which runs it after the command, with SDK 0.8.0-preview.4:

// A synchronous Main, or no await before this line: the thread is the process main thread.
return new CommandApp(GeneratedCommandCatalog.Create()) { Name = "my-app" }.Run(args);

internal static class WindowCommands
{
    [Command("ui", Description = "Open the main window.")]
    internal static async Task Ui(CommandExecutionContext context,
        [Option("--settings")] string? path = null, CancellationToken cancellationToken = default)
    {
        // Asynchronous work and its failures belong to the command, before the host starts.
        AppSettings settings = await AppSettings.LoadAsync(path, cancellationToken);
        context.ContinueOnCallingThread(() => DesktopEventLoop.Run(new DesktopHostOptions(), async desktop =>
        {
            await using var provider = new ServiceCollection()
                .AddSingleton(settings)
                .AddScoped<MainViewModel>()
                .AddRunicViews()
                .BuildServiceProvider();
            var host = new RunicDesktopHost(provider, desktop);
            await using var window = await host.OpenWindowAsync<MainWindow>();
            await window.WaitForCloseAsync();
            return 0;
        }));
    }
}

Capture values such as settings, not the command's scoped services. See from a command line and start a UI host on the main thread.

Translate a CLI #

Help, parse errors and faults are English by default. The Runic.Translations.CommandLine adapter, which Runic Translations publishes, translates them with a Translations catalog. It ships English and German text for every framework key, including the prompt text that Command Line 0.7.0-preview.1 added and the response-file text of 0.9.0, and it looks up your own command descriptions in your catalog. The adapter follows each Command Line minor in lockstep: Translations 0.16.x depends on Command Line [0.15.0, 0.16.0-0.0), Translations 0.15.x on [0.14.0, 0.15.0-0.0), Translations 0.14.0, 0.13.0, 0.12.0 and 0.11.0 on [0.13.0, 0.14.0-0.0), Translations 0.10.0 on [0.12.0, 0.13.0-0.0), and Translations 0.9.1 on [0.9.1, 0.10). Command Line 0.10 and 0.11 have no adapter, and a mismatched pair fails restore with NU1608. Since 0.12.0 the English and German framework text (the runic-command-line catalog) ships with Runic.CommandLine itself, and the adapter compiles exactly that release's text. Add the adapter and the build package to the project from your first command:

dotnet add package Runic.Translations.CommandLine --version 0.16.0
dotnet add package Runic.Translations.Build --version 0.16.0

The build package compiles a translations/ folder next to the project file. Create translations/runic.json:

{
  "schemaVersion": 1,
  "catalog": "hello",
  "code": { "namespace": "HelloCli.Translations", "className": "HelloText" },
  "baseLocale": "en",
  "locales": ["en", "de"]
}

translations/en.rmf2 defines every message in English:

commands {
  greet = Say hello.
}
greeting =
  .input {$name :string}
  {{Hello, {$name}!}}

translations/de.rmf2 has the same keys in German:

commands {
  greet = Grüßt eine Person.
}
greeting =
  .input {$name :string}
  {{Hallo, {$name}!}}

Then give CommandApp the resolver and the commands a translation manager:

using System.Globalization;
using HelloCli.Translations;
using Runic.CommandLine;
using Runic.CommandLine.Generated;
using Runic.Translations;
using Runic.Translations.CommandLine;

// Under LANG=C the invariant culture has no name; the catalog then uses its base locale.
ITranslationManager manager = HelloTextCatalog.CreateManager(
    initialLocale: CultureInfo.CurrentUICulture.Name);

return await new CommandApp(GeneratedCommandCatalog.Create())
{
    Name = "hello",
    TextResolver = new TranslationCommandTextResolver(manager),
    ScopeFactory = CommandScopes.FromServices(CommandServices.Empty.With(manager)),
}.RunAsync(args);

internal static class Commands
{
    [Command("greet", Description = "Say hello.", DescriptionKey = "commands.greet"), DefaultCommand]
    internal static string Greet([Argument] string name, [FromServices] ITranslationManager translations) =>
        new HelloText(translations).Messages.greeting(name);
}

With a German display language, hello --help starts with Aufruf: hello <Befehl> [Optionen] and lists greet as Grüßt eine Person., and hello Ada prints Hallo, Ada!. A locale the catalog does not have, such as French, gets English. The same text appears in the JSON message fields; command names, option spellings, codes and messageKey values never change.

  • Resolver. TranslationCommandTextResolver looks up each key in your catalog and in its English and German text, and otherwise leaves Command Line's English text. Framework text is overridden only in translations/overrides/runic-command-line/<locale>.rmf2, listed as { "catalog": "runic-command-line", "from": "Runic.Translations.CommandLine" } under overrides in runic.json, with AppTextCatalog.Overlays registered on a context-based resolver. Translations 0.14 deprecated the second path, a message in your own catalog named after a framework key, and 0.15 removes it: such a message has no effect, and the build reports it as warning RTR0107; see Upgrading to 0.15.1. Since Translations 0.9.1 the lookup is locale-first: for each locale of the requested locale's fallback chain your message comes before the built-in one, so the built-in German beats an override your catalog has only in English. Pass the manager to follow locale switches, an ITranslationSnapshot for one fixed locale, or an ITranslationContext or a TranslationContextBuilder to resolve in the invocation's culture and to add languages with overlays, such as French packs. A message name is the key with each hyphen removed and the next letter capitalized: help.show-help is help.showHelp. The framework text keys list every key and its arguments.
  • CommandScopes. CommandScopes.FromServices makes application-owned objects available to [FromServices] parameters without a dependency-injection package. Use CommandScopes.FromServices(provider) for an existing IServiceProvider, or CommandScopes.Create(provider.CreateAsyncScope, scope => scope.ServiceProvider) for one scope per invocation. Take ITranslationManager and create HelloText in the method: the Command Line generator cannot use a type that another source generator creates, such as HelloText, as a parameter (RCLI9003).
  • RUNIC_COMMANDLINE_DEBUG. A DescriptionKey that the catalog does not have falls back to Description without an error. Set RUNIC_COMMANDLINE_DEBUG=1 to have help print each one to stderr as an RCLI0023 warning. In a test, new CommandTextContext(culture, resolver).ValidateDescriptionKeys(catalog) returns the same issues. The same variable writes the exception of an RCLI5000 host failure to stderr.

An application that already uses a translation context can call AddRunicCommandLineTranslations(applicationCatalogId) (since Translations 0.10.0) instead: it adds runic-command-line to the shared context and registers the resolver, so one SetLocaleAsync switches the application's text and the command line's together. When your catalog has the requested language and the framework text does not, the resolver writes one warning: line to standard error; an override file in translations/overrides/runic-command-line/ adds that locale.

The Runic.Translations.CommandLine README describes the resolver in full.

New in 0.15.0 #

Command Line 0.15.0 is the first release of the 0.24 release train, before Runic Translations 0.16 and Runic SDK 0.24. Its public API is unchanged (package validation against 0.14.0 is clean). It decides the behaviours the specification had only described, so some catalogs that built before now fail validation.

  • --version only in root help. tool <command> --help and a group's help no longer list the --version Show version row; tool --help keeps it. Parsing is unchanged: tool --version writes the version, and tool <command> --version is still unknown-option (RCLI1001).
  • Catalog codes for global options, fallbacks and choices. A global option that is not a flag or a single value is RCLI0028, choices on a flag are RCLI0029 (the generator reports RCLI9047 for Choices on a bool option), and an environment variable on an option that needs two or more values is RCLI0030. A command option with a global option's ID must agree with it completely (RCLI0019); its own help members now win over the global option's.
  • A root command's usage hint is root help's: a usage error ends with Usage: tool [command] <target> [options] and Run "tool --help" for more information., and a root command's name is no longer suggested for a mistyped command.
  • Negative numbers are checked against the argument that positional binding gives them, so plot x -3 binds -3 to a later argument that accepts negative numbers.
  • Signal registration that fails with an IOException, UnauthorizedAccessException or Win32Exception keeps the runtime's default handling and the invocation runs, as on an unsupported platform.
  • The strict reader reports malformed-json for an escape that decodes to an unpaired UTF-16 surrogate anywhere in a frame.
  • Old-name guards for the Runic Artifex rename ship in buildTransitive/Runic.CommandLine.targets (RCLI7001–RCLI7003). They list no name yet, so nothing reports them in this release.
  • Specifications for other implementations: the protocol, grammar, hosting, help and human output specifications with their corpora (453 cases), which a language-neutral conformance driver in eng/conformance runs. Nothing changes for applications.

Upgrading from 0.14 #

Nothing is removed. Check:

  • A global option that takes several values, repeats, is required or is sensitive: declare CommandArity.Zero or CommandArity.ExactlyOne, or declare the option on each command. GlobalOption no longer throws ArgumentException; catch CommandCatalogValidationException from Build.
  • A command option that restates a global option with other settings (repeats, required, sensitive, another environment variable or other choices, negative numbers): give it the global option's settings, leave out the variable and choices to inherit them, or use another ID.
  • Remove choices from flags, and environment variables from options whose minimum is two or more values.
  • Update tests that compare a command's or a group's help text (remove the --version row) or the standard error of a root command's usage error. Scripts that matched the code of --profile --help (now missing-option-value) or of a mistyped root command (now unexpected-argument, RCLI1006) see new codes; the exit code (2) is unchanged.
  • German text needs Runic.Translations.CommandLine 0.16, which pairs with Command Line 0.15 (NU1608 for a mismatched pair). The catalog's keys and text are those of 0.14. Runic SDK 0.24 bundles Command Line 0.15.0 in dotnet-runic, Runic.Create and the Runic.Assets packer.

The 0.15.0 release notes list every change.

New in 0.14.0 #

Command Line 0.14.0 is the first release of the 0.23 release train, before Runic Translations 0.15 and Runic SDK 0.23. Its public API is unchanged except that CommandTextKeys.FaultPromptUnavailable is now [Obsolete].

  • Every framework key has a catalog message. The RCLI4001 fault (a prompt that cannot ask) always shows the text of its diagnostics.prompt-* diagnostic, translated like every other diagnostic, and the faults.RCLI4001 key is retired.
  • Duplicate member names are rejected everywhere. The strict reader (CommandJsonEnvelopeReader and the testing helpers built on it) checks every object of a frame, also inside members it does not know, and raises duplicate-property, as the protocol requires.
  • Smaller NativeAOT executables. CommandUnit payloads are written by a value converter, and the framework checks its enum arguments with range checks: a linux-x64 executable whose commands return text shrinks by about 41 KB (hello-world: 3,634,216 → 3,593,016 bytes). The API and the JSON output stay the same.

Upgrading from 0.13 #

Nothing is removed. Check:

  • An application that defined faults.RCLI4001, through Translations' removed second override path or its own ICommandTextResolver, overrides diagnostics.prompt-requires-terminal, diagnostics.prompt-json-output and diagnostics.prompt-disabled (argument prompt) instead, for example in translations/overrides/runic-command-line/<locale>.rmf2, and removes the faults.RCLI4001 message.
  • A producer that writes a duplicate member name inside an unknown member at the root, in fault or in a diagnostic writes each name once per object; such a frame was accepted before.
  • German text needs Runic.Translations.CommandLine 0.15, which pairs with Command Line 0.14 (NU1608 for a mismatched pair). Runic SDK 0.23 bundles Command Line 0.14.0 in dotnet-runic, Runic.Create and the Runic.Assets packer.

The 0.14.0 release notes list every change.

New in 0.13.0 #

  • Help and usage errors name what users see. The missing-argument error (RCLI1005) names the argument by its placeholder, as the usage line does: The <destination> argument is missing. Help lists arguments the same way under "Arguments", and its [requires: …] and [conflicts: …] notes name options by their spelling in the catalog's dialect (--factor or /factor) instead of their ID.

  • A binding member in JSON diagnostics. A diagnostic that names one declared argument or option (missing-argument, missing-option-value, duplicate-option, missing-required-option, invalid-choice, the value errors such as invalid-integer and others) carries its ID in the new optional binding member, CommandDiagnostic.Binding in .NET. It stays the same whatever the value name, dialect or culture:

    {
      "code": "RCLI1005",
      "kind": "missing-argument",
      "arguments": ["<container-path>"],
      "binding": "container-path"
    }
    
  • No default for flags in help. An option that takes no value shows no [default: False], and the generator records no CommandHelp.DefaultValue for it. Value options keep their defaults, such as [default: 1.5].

  • A text key for extended help. [Command] and [CommandGroup] take LongDescriptionKey, which help resolves through the application's ICommandTextResolver as it does DescriptionKey, with LongDescription as the fallback. CommandTextContext.ValidateDescriptionKeys reports an unresolved one as RCLI0023.

Upgrading from 0.12 #

Nothing is removed, and the API changes are additive. Check:

  • Tests and JSON consumers that compare RCLI1005's message or arguments expect the placeholder (["<destination>"]). A script that read the argument's ID from arguments reads binding instead. Kind, code and messageKey (diagnostics.missing-argument) are unchanged.
  • Strict readers that reject unknown diagnostic members accept binding. Version-1 readers, including CommandJsonEnvelopeReader before 0.13, ignore it; CommandTestEnvelope 0.13 accepts it.
  • Tests that compare help text expect the placeholders under "Arguments", the option spellings in [requires: …] and [conflicts: …], and no default for flags; a generated Boolean option's CommandHelp.DefaultValue is null.
  • German text needs Runic.Translations.CommandLine 0.11.0.

The 0.13.0 release notes list every change.

New in 0.12.0 #

  • Windows slash dialect. GeneratedCommandCatalog.Create(builder => builder.Syntax(CommandSyntaxDialect.WindowsSlash)) accepts /name, /name value, /?, /help and /version alongside the portable spellings, and help, usage hints and suggestions use the dialect's spelling. CaseInsensitive() matches commands and options ignoring case, Spelling = "resetAll" gives a command a display spelling, and HelpOrder(CommandHelpOrder.Declaration) lists commands in source order. A catalog that declares none of these parses exactly as before.
  • An exit code per outcome. CommandOutcome<T>.WithExitCode(int) sets the process exit code of one outcome, including an informational success code such as 3010, and [CommandExitCode(code, "description")] adds an "Exit codes:" section to help.
  • --json for every outcome. CommandApp.JsonOutput with DocumentEveryOutcome, QuietStandardError and ASCII Escaping; all are off by default.
  • Every framework text has a key, including the process faults RCLI6001 to RCLI6011, the help link and the redaction notes.

Upgrading from 0.11 #

Nothing is removed, and an application that declares none of the new options parses, exits and writes JSON as before. Check:

  • German usage errors use new wording, such as Die Option '--x' ist unbekannt.
  • An empty command line has the messageKey diagnostics.missing-command instead of diagnostics.unknown-command; kind and code (RCLI1002) stay.
  • RCLI6008 and RCLI6011 have one English message each, and ProcessResult.EnsureCompleted reports RCLI6006.
  • SpectreCommandConsole writes no ANSI escapes for redirected output or color: false on CI hosts.
  • A success envelope may carry a nonzero informational exitCode; readers of runic.commandline/1 before 0.12 reject such a frame.
  • diagnostics.invalid-choice-hidden takes a second argument, help.
  • German text needs Runic.Translations.CommandLine 0.10.0.

The 0.12.0 release notes list every change.

Next steps #